You can save to the database, or use SharedPreferences
, which I believe is the simplest way:
To facilitate, I recommend creating a class that contains the values you wanted to save:
class Valores
{
boolean check1;
boolean check2;
boolean check3;
boolean check4;
}
Method to save this class:
/**
* seta os valores no SharedPreferences
* @param valores
*/
public void setValores(Valores valores)
{
// passamos o nome do objeto que vamos criar e o modo de armazenamento
final SharedPreferences prefs = getApplicationContext().getSharedPreferences("VALORES_TELA_UM", Context.MODE_PRIVATE);
final SharedPreferences.Editor editor = prefs.edit();
// setamos o nome da propriedade e o valor
editor.putBoolean("CHECK1", valores.check1);
editor.putBoolean("CHECK2", valores.check2);
editor.putBoolean("CHECK3", valores.check3);
editor.putBoolean("CHECK4", valores.check4);
// commitando as alteracoes
editor.commit();
}
Method to redeem values:
public Valores getValores()
{
Valores valores = new Valores();
final SharedPreferences prefs = getApplicationContext().getSharedPreferences("VALORES_TELA_UM", Context.MODE_PRIVATE);
valores.check1 = prefs.getBoolean("CHECK1", false);
valores.check2 = prefs.getBoolean("CHECK2", false);
valores.check3 = prefs.getBoolean("CHECK3", false);
valores.check4 = prefs.getBoolean("CHECK4", false);
return valores;
}