0

I have an ActivityA, which starts ActivityB through Intent's startActivity() method.The context is as below:

A.java

String name = edittext.getString();  
Intent i = new Intent(A.this,B.class);  
Bundle b = new Bundle();  
b.putString("Name",name);  
i.putExtras(b);  
startActivity(b);  

B.java

Bundle bb=getIntent().getExtras();
String namee=bb.getString("name");

In this B Activity there will be Back button which when clicked takes control back to A as below:

     back.setOnClickListener(new OnClickListener()
    { 
        public void onClick(View arg0) {
   Intent backToDetails = new Intent(B.this,A.class);
   startActivity(backToDetails);
}
     });


Now control comes to ActivityA. When I again start Activity B from Activity A , the previous value of the name is lost .So, I again get new Value by overwrting old value in Activity B. So, how to save previous name value ? How to save the state of Activity B? Can any one help me in sorting out this issue?

Thanks In Advance,

Nishant
  • 32,082
  • 5
  • 39
  • 53
Android_programmer_camera
  • 13,197
  • 21
  • 67
  • 81

1 Answers1

2

You just have to save the state of your activity B. In this related question there is a complete answer to solve your problem. Good luck!

Community
  • 1
  • 1
Antonio
  • 3,128
  • 2
  • 22
  • 14