Reputation: 5063
I am trying to make use of the ResourceBundle
class in my application. I am still confused/stuck in instantiating the whole thing. Especially pointing the ResourceBundle
to my res folder where I have values-en
, values-fr
, values-sw
and so on.
I have tried the following:
resourceBundle = ResourceBundle.getBundle(basename, locale);
where basename
:
"myclasspackage"
"res"
"/data/data/myclasspackage/project.properties"
All of the initializations give me the same, NullPointerExpection
. Please please help me.
Upvotes: 2
Views: 1761
Reputation: 9625
To access resources from a different configuration:
Resources res_curr_conf = getResources();
Configuration c = new Configuration(res_curr_conf.getConfiguration());
c.locale = whateverLocaleIWant();
Resources res_alt_conf = new Resources(res_curr_conf.getAssets(), res_curr_conf.getDisplayMetrics(), c);
// TODO - use res_alt_conf
Upvotes: 1
Reputation: 1006944
ResourceBundle
is for old-style Java resources in JAR files and have nothing to do with Android's resource system.
Upvotes: 2