Possible duplicate:
How to save Android application state?
I am currently working on an application that has the following behavior: I use 2 Edittext, and there is some value that I enter into it, and when I click the button it will go to the next page or activity. But the problem is here, when I return to activity, I do not find the value in edittext PLease, help me .. Please let me know the code ... Thanks in Advance ....
This is my code ....
public class TestsampleActivity extends Activity { Button b1,b2; TextView t1; EditText e1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); b1= (Button)findViewById(R.id.btn1); b2= (Button)findViewById(R.id.btn2); t1=(TextView)findViewById(R.id.tv1); e1=(EditText)findViewById(R.id.et1); b1.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ add(); } }); b2.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ del(); } }); } public void add() { String s1= e1.getText().toString(); Intent intent=new Intent(this,next.class); intent.putExtra("name",s1); startActivity(intent); } public void del() { e1.setText(""); t1.setText(""); } }
source share