View with id must save and restore their state automatically ( within the application session ), but if this does not happen, you can implement the state saving manually, for example:
public class MainActivity extends AppCompatActivity { private static final String EDIT_TEXT_SAVE_KEY = "EDIT_TEXT_SAVE_KEY"; private EditText mEditText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mEditText = (EditText) findViewById(R.id.edit_text); if (savedInstanceState != null) { String savedText = savedInstanceState.getString(EDIT_TEXT_SAVE_KEY); mEditText.setText(savedText); } } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString(EDIT_TEXT_SAVE_KEY, mEditText.getText().toString()); } }
In order to avoid boilerplate code, you can use Icepick .
If this advice does not help, then the application is unloaded from memory, and resetting the state of the application is normal. If, on the SharedPreferences , it is important to save data from input fields, you can use, for example, SharedPreferences .