tags:

views:

67

answers:

1

I have an activity A, 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,

+1  A: 

Hi! 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!

Antonio
btw, if there is no saved state you should read the extra values in the Intent
Antonio