I want to let the user change the language of my application using spinner (or any way). I tried many ways but they change the language of this activity not all activities, and I want to save it so when the user restart the app he will find the last choosed language.
You'll find this screen either in the System Settings app: Languages, or System Settings: System: Languages and input. The Language preference screen should contain one entry called “English (Europe)”. Click Add language and add a fallback language.
you can use this code in spinner or any way you want
String languageToLoad = "en"; // your language Locale locale = new Locale(languageToLoad); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
then you should save the language like this
SharedPreferences languagepref = getSharedPreferences("language",MODE_PRIVATE); SharedPreferences.Editor editor = languagepref.edit(); editor.putString("languageToLoad",languageToLoad ); editor.commit();
and use the same code in every activity in onCreate()
to load the languageToLoad
from the SharedPreferences
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With