Change language in the app and stay changed

0

I have an app and would like the user to change it if he / she wants to

Following this link worked fine, however if I clean the cache of the phone (I think that's it) or clean all the screens open and try to open again, it does not stay with the language chosen.

How would you do that when he returned to the app recognize the changed language. I thought about saving the language in the database and retrieving it, however after I clear the cache it gives the message waiting for the debugger

After I entered this code:

try {
            database = new Database(this);
            conn = database.getWritableDatabase();
            repositorioLocale =  new RepositoriosLocales(conn);
            int lingua = repositorioLocale.getIntLocale();
            if(lingua > 0){
                idioma = repositorioLocale.getRecLocale();
                setLocale(idioma);


           }else{

                repositorioLocale.inserirLocale(getResources());

            }

        }catch (SQLException ex){

        }
    
asked by anonymous 25.11.2016 / 12:52

2 answers

1

Placing a database is an option, but I think it is not justified, if it is just to save the language. Search for SharedPreferences, which is another way to save data and works through {key, value}, is quite simple to use.

    
26.11.2016 / 19:58
1

Instead of the database, I think you could use SharedPreferences.

It uses the same logic, and is most recommended for these purposes!

    
26.11.2016 / 21:37