I have a requirement to change my application language from English to Hindi.I am not able to do so in Android 8.0
public static void setUpLanguage(SqrrlApplication application, String languageIsoCode) {
try {
Locale locale = new Locale(languageIsoCode);
Locale.setDefault(locale);
Resources res = application.getResources();
Configuration config = new Configuration(res.getConfiguration());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
config.setLocale(locale);
application.getApplicationContext().createConfigurationContext(config);
}else{
config.locale = locale;
}
res.updateConfiguration(config, res.getDisplayMetrics());
} catch (Exception e) {
e.printStackTrace();
}
}
Please Note: However, if I change my device language from device settings, my app changes to hindi version.
I have 'values-hi' folder in res having the hindi strings.
Thanks.