I currently have an application where the french users should have a preference set to false by default and the other one should have this preference set to true.
I don’t understand a correct and clean way to handle that.
Currently , in my app, I call 2 times the preference.
*) first time in my preference xml layout and in my preference activity, I have to set the preference at the first launch.
*) Second time, in my code:
boolean value = prefs.getBoolean("key"), true/false);
Thanbk a lot for all your ideas and explanations on how to make this in a clean way.
You can use resources in such a way to accomplish this.
Folder structure (you can probably pick whatever name you want for the actual XML file or even create the resource with other resources):
In
/res/values/bools.xml:In
/res/values-fr/bools.xml:In your preferences.xml:
All set!
You should even be able to access that from code with
R.bool.pref_default.Disclaimer: I have never written code that involved multiple languages, but I have based this on my understanding of resource qualifiers.
If you mean the region France and not the French speakers, then you can probably find a
-rqualifier for it (see my link).