I have a problem in changing locale, I have tried this https://stackoverflow.com/a/40704077/2199589 and the following snippet with both BaseContext and ApplicationContext, none of them works well. I have saved the current language in share preference. Even that value is correct, string resources are not updating as the way they should be.
public void changeLanguage(String languageToLoad) {
showLog("Language to be loaded :- "+ languageToLoad);
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration(getApplicationContext().getResources().getConfiguration());
config.setLocale(locale);
getApplicationContext().getResources().updateConfiguration(config,getApplicationContext().getResources().getDisplayMetrics() );
}
I have updated the UI after calling this method, and the UI actually did the refresh. So any idea what went wrong? Please help me with this.