I am changing the application locale based on user choice. Independent of device locale.
using
public void setDefaultLocale(Context context, String locale) {
Locale appLoc = new Locale(locale);
Locale.setDefault(appLoc);
Configuration appConfig = new Configuration();
appConfig.locale = appLoc;
context.getResources().updateConfiguration(appConfig,
context.getResources().getDisplayMetrics());
}
But I want to know what will be the device locale also.
When I am trying to get this I always getting the locale which I have set to application.
ex: applictaion is in ENGLISH and device is in CHINESE. I am always getting english.
for getting locale using,
option 1.
String locale = context.getResources().getConfiguration().locale.getCountry();
option 2.
String local_country = ((Activity) context).getBaseContext().getResources().getConfiguration().locale.getCountry();
Any help will be highly appreciated!!!