How Do I Save User's Locale Settings (in App)?
I'm making an app that has two available languages. User is changing between languages with a button click. Here are my onClick methods: public void setLocaleEng(View v){ Local
Solution 1:
If the answer is Shared Preferences, then how? I've only used shared preferences to store strings.
Yes, answer is SharedPreferences and you can use it to store Strings, just like you did before. Just make it store "en" or "sl" and then
StringenOrSlReadFromSharedPrefs= readSharedPrefsJustLikeYouDidBefore();
Localelocale=newLocale(enOrSlReadFromSharedPrefs);
Locale.setDefault(locale);
ConfigurationconfigSlo=newConfiguration();
configSlo.locale = localeSlo;
getBaseContext().getResources().updateConfiguration(configSlo, getBaseContext().getResources().getDisplayMetrics());
Intentintent=newIntent(NastavitveJezika.this, MainActivity.class);
finish();
startActivity(intent);
Post a Comment for "How Do I Save User's Locale Settings (in App)?"