Load language specific string from resource?
android, resources, string
Solution
Looking in the documentation, this looks promising:
Resources standardResources = context.getResources();
AssetManager assets = standardResources.getAssets();
DisplayMetrics metrics = standardResources.getDisplayMetrics();
Configuration config = new Configuration(standardResources.getConfiguration());
config.locale = Locale.US;
Resources defaultResources = new Resources(assets, metrics, config);
In other words, create a new Resources object configured to a standard locale.
Problem
At one point in one of my Android apps I need to load strings of a specific language. For example: ``` values: <string name="txt_help">Help</string> values-de: <string name="txt_help">Hilfe</string> values-fr: <string name="txt_help">Aider</string> ``` Now I need the default (values) text. Is there a way to load the key "txt_help" with a given language "en"? I can't find a method where I can set a locale as an additional parameter. Or can I create a new ResourceManager with a given locale and read the String through this resource object? Many thanks in advance. hjw