0

I have 5 EditText and there is a button, on clicking of that button it brings the user to the next Activity where user can see some information and after the user seen the information he cancel that activity and go back to first activity. But at this time the values entered in the Edittext is removed. So I want to remain that values on coming back to the previous Activity.

Abid Khan
  • 2,451
  • 4
  • 22
  • 45

3 Answers3

0

on the Button click of first activity start new activity without finishiing it and on the second activity click back button click finish your current activity this will bring your first activity on resume state

First Activity on click of button:

mBtnNext.setOnClickListener(new View.OnClickListener() {    
            @Override
            public void onClick(View v) {                        

                    startActivity(new Intent(ActivityFirst.this,ActivitySecond.class));}

        });

Second Activity Button Click:

mBtnBack.setOnClickListener(new View.OnClickListener() {    
                @Override
                public void onClick(View v) {                        

                        finish();}

            });
jyomin
  • 1,957
  • 2
  • 11
  • 27
0

You can go for overriding protected void onSaveInstanceState(Bundle outState) and protected void onRestoreInstanceState(Bundle savedInstanceState)

Here is an example

Remember it will work when you will not finish your previous activity.Do this in your first activity

Refer this link

Community
  • 1
  • 1
Lokesh
  • 5,180
  • 4
  • 27
  • 42
0

There is different way to this Task But one of Them is You can use Shared Preference

In Shared preference Store your Edit Text value . When You come back to Your First
Activity from Second activity Fetch Edit text value from Shared preference and Print that value in Edit text.

Thank You.