I have a fragment with EditText. I enter text into EditText. I press the button. I open next fragment . Current fragment Replace. How can I save the data entered in the EditText and get them again when I go back to the first fragment? It suggests itself
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString("code", getTextField().getText().toString());
textCode = getTextField().getText().toString();
}
but he did not call. I read and learned that it is called if I wring such a program. I checked and so called. But as I call it when I call a new fragment , and they Replace old? Or maybe there are other options to preserve the value? Static variable global, SHARED preferens - not good.
Aucun commentaire:
Enregistrer un commentaire