I’ll better explain the problem with an example: Lets suppose I’m creating a library (.jar) where one of the methods is:
String getInternetStatus();
It should return a language localized String describing the status of the internet connection but if I use the Context given by the application for retrieve the String it will fail right?
Is possible to define locale Strings in the library?
You can store localized strings in a library. Just create a strings.xml file in the appropriate directory in your library – res/values for your default locale, or res/values-de if for example you wanted to provide German versions of your strings.
Your getInternetStatus() method can then be changed to provide a status variable – boolean for just up/down, or an int to represent a range of values. Then use a case statement to decide which string you are going to display to the user. Getting the localized string at this point looks something like this:
context.getResources().getString(R.string.summary)
Anthony Nolan