How to go back to the previous activity?
<p>I am developing an application with 5 interfaces</p>

<p>I have an activity where the user has to enter a password,  after entering it the user moves to the next activity, but when the user clicks on back button and he's returned to the password activity, the entered password is missing... how can I maintain the entered password?</p>

<p>Code:</p>

<pre><code>back = (Button) findViewById(R.id.back);
back.setOnClickListener(new View.OnClickListener() {    

        public void onClick(View v1) {
            Intent backIntent = new Intent();
            backIntent.setClass(getApplicationContext(), LockAppActivity.class);
            backIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
            startActivity(backIntent);
            finish();
        }
    });
</code></pre>

<p>Suppose the app starts with activities A --> B --> C --> D --> E</p>

<p>When user moves to B from C, and at activity B there is a "deactivate" button and when the user presses it all the user settings are cleared and the application will exit, but when I press the button, it brings me to the layout C... how can I change this?</p>

<pre><code>    deactivate = (Button) findViewById(R.id.deactivate);
    deactivate.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v){ 
            final String STORAGE = "UniqueID_IMSI";
            SharedPreferences unique = getSharedPreferences(STORAGE, 0);
            SharedPreferences.Editor editor1 = unique.edit();
            editor1.putString("identifier", "");
            editor1.putString("simIMSI", "");
            editor1.commit();

            final String LOGIN_PASSWORD = "Login_Password";     
            SharedPreferences loginPassword = getSharedPreferences(LOGIN_PASSWORD, 0);
            SharedPreferences.Editor editor2 = loginPassword.edit();
            editor2.putString("loginPassword", "");
            editor2.commit();

            final String LOCK_APP_PASSWORD = "LockAppPassword";
            SharedPreferences userPassword = getSharedPreferences(LOCK_APP_PASSWORD, 0);
            SharedPreferences.Editor editor3 = userPassword.edit();
            editor3.putString("password", "");
            editor3.commit();

            final String PHONE_NUMBER = "Phone_Number";         
            SharedPreferences phone = getSharedPreferences(PHONE_NUMBER, 0);
            SharedPreferences.Editor editor4 = phone.edit();
            editor4.putString("phoneNumber", "");
            editor4.commit();

            finish();
        }
    });
}
</code></pre>
