Change language in the app and stay changed

Asked

Viewed 96 times

0

I have an app and I would like the user himself to change if you want

Following this link even worked, but if I clear the cache of the mobile phone (I think that’s it) or clean all open screens and try to open again, it does not remain with the chosen language.

How would you make it so that when he returned to the app he recognized the changed language. I thought to save the language in the database and recover, but after I clear the cache gives the message of waiting for the Debugger

inserir a descrição da imagem aqui

After I entered that 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){

        }
  • on hold, for you this is easy

2 answers

1


Putting a database is an option, but I don’t think it’s justified if it’s just to save the language. Research on Sharedpreferences, which is another way to store data and works through {key, value}, is quite simple to use.

  • even so, clear the cache it does not remain with the language

  • I got it. I guess that’s what it was. Thank you!

1

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

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

  • even so, clear the cache it does not remain with the language

Browser other questions tagged

You are not signed in. Login or sign up in order to post.