Possible Duplicate:
Change app language programmatically in Android
I want to change language in my SettingsActivity.java
for all Activities immediately.
And save this choice (even when I exit from app or reboot phone) regardless of system locale.
How can I do that?
public class MyOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
switch (pos) {
case 0:
Locale locale = new Locale("en");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext()
.getResources().getDisplayMetrics());
break;
case 1:
Locale locale2 = new Locale("de");
Locale.setDefault(locale2);
Configuration config2 = new Configuration();
config2.locale = locale2;
getBaseContext().getResources().updateConfiguration(config2, getBaseContext()
.getResources().getDisplayMetrics());
break;
}
}
public void onNothingSelected(AdapterView<?> parent) {
// Do nothing.
}
}