code: @Override
    protected void onStop()
    {
      super.onStop();
  
      String email = emailField.getText().toString();
  
      if( email == null )
        return;
  
      SharedPreferences settings = getSharedPreferences( PREF_TAG, 0 );
      SharedPreferences.Editor editor = settings.edit();
      editor.putString( EMAIL_PREF, email );
      editor.commit();
    }
docs: Lifecycle section