Thanks for all your help. I worked it out my way. Here is the code for
a getLocalizedMessage in a custom exception:
public String getLocalizedMessage() {
Context c = LearningWordsApplication.getContext();
int id = R.string.error_unknown;
switch (error) {
case ERROR_CANNOT_CREATE_DIR:
id = R.string.error_directory_cannot_be_created;
break;
case ERROR_CANNOT_CREATE_FILE:
id = R.string.error_file_cannot_be_created;
break;
case ERROR_WEIRD_WRITING:
id = R.string.error_weird_writing;
break;
case ERROR_CANNOT_READ:
id = R.string.error_cannot_read_file;
break;
case ERROR_NO_CHARSET_FOR_READER:
id = R.string.error_no_charset_for_reader;
break;
case ERROR_CANNOT_FIND_EXTERNAL_STORAGE:
id = R.string.error_cannot_find_external_storage;
break;
default:
id = R.string.error_unknown;
}
String msg = c.getResources().getString(id);
String result = null;
if (paramTwo != null && paramOne != null) {
Object[] args = { paramOne, paramTwo };
result = MessageFormat.format(msg, args);
}
else if (paramOne != null) {
Object[] args = { paramOne };
result = MessageFormat.format(msg, args);
}
return result;
}
As you see, a R.string.* Messages uses localized files, the android
localizing method and those contain the MessageFormat for the creation
of preformatted messages.
Cheers,
R.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en