Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Set Default Language for Android app?

Tags:

java

android

I've created an app in two languages. The second one (english), is used when user's default system language is english. If it's not, then the first one is used.

I want to set the second language (that's english) as a DEFAULT language, which means that when user opens my app and his system language is not the first one, nor English, the English language will appear as a default one.

I tried:

    Locale locale = new Locale("en_US");
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    context.getApplicationContext.getResources().updateConfiguration(config, null);

But got "context cannot be resolved" error everytime.. Is this piece of code right or..?

like image 451
user3053246 Avatar asked May 23 '14 21:05

user3053246


1 Answers

Okay,

to make everything clear, I realized res/values is a DEFAULT directory and the others are just "in case of language". So everything I had to do was to switch the english to /res/values and the other language goes to res/values-es

like image 63
user3053246 Avatar answered Oct 17 '22 22:10

user3053246