Android Locale : Configure locale for canadian english and normal english

1.2k Views Asked by At

In a multi-language app, when i am using default language(English) it picks up the strings.xml from the default (res/values) folder. Whereas for canadian english also it uses from the same folder(res/values). As per android standard, It has to pick up from the corresponding folder(res/values-en-rCA).

I dont know where i am going wrong. Will it take according to the device language ?

Locale code used :

English - en

English/Canada - en_CA

1

There are 1 best solutions below

8
On
You need to set the locale in order to load the proper resources.


 DisplayMetrics metrics = getApplicationContext().getResources().getDisplayMetrics();
 Configuration configuration = new Configuration();
 Locale locale = new Locale("en_CA");
 configuration.locale = locale;
 Locale.setDefault(locale);
 res.updateConfiguration(configuration, metrics);