Search code examples
androidandroid-edittext

EditText return back previously input data after pressed back button


I have an application login system type of application. Once the user pressed back button after login, the username and password EditText are filled with what the user enter just now. Is there any way to clear the EditText to empty? Sorry that if I make this sounds confusing. Any comment will be appreciated!


Solution

  • you can do this by overriding onPause method of Activity and in onPause method clear all EditText Value as:

    @Override
     protected void onPause(){
            super.onPause();
    
             // Clear all value here
            editTextone.setText("");
            editTexttwo.setText("");
        }