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
String enOrSlReadFromSharedPrefs = readSharedPrefsJustLikeYouDidBefore();
Locale locale = new Locale(enOrSlReadFromSharedPrefs);
Locale.setDefault(locale);
Configuration configSlo = new Configuration();
configSlo.locale = localeSlo;
getBaseContext().getResources().updateConfiguration(configSlo, getBaseContext().getResources().getDisplayMetrics());
Intent intent = new Intent(NastavitveJezika.this, MainActivity.class);
finish();
startActivity(intent);
Post a Comment for "How Do I Save User's Locale Settings (in App)?"