To help follow example using Sharedpreferences I took from a project of mine:
public static final String MY_PREFS = "MEUAPP";
SharedPreferences preferences = getSharedPreferences(MY_PREFS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.clear(); // No teu caso pode retirar o clear, eh que eu precisava que começasse vazio
editor.apply();
// Utilizo esse objeto collegeData pq estou pegando a informação de um retorno json, mas vc pode utilizar um TextView ali
editor.putInt("id", Integer.parseInt(collegeData.getString("id")));
editor.putString("nome", collegeData.getString("nome"));
To get the info you saved earlier just declare Sharedpreferences again in the Activity you want.
public static final String MY_PREFS = "MEUAPP";
TextView name = (TextView) header.findViewById(R.id.nome_menu);
SharedPreferences prefs = getSharedPreferences(MY_PREFS, MODE_PRIVATE);
name.setText(prefs.getString("nome", null));
Sharedpreferences
– Dev
See if that’s the answer of this question or of that help you.
– Zulian
Sharedprefences? Sorry, could you specify better? because I’m used to taking an Edittext value and then saving it from there, I never did with already defined Array phrases
– L.jack