Android 如何在活动更改时显示EditText数据

Android 如何在活动更改时显示EditText数据,android,Android,大家好,朋友们,我的程序中有编辑文本,如果我在上面写了一些东西,如果我正在点击其他选项,它将移动到另一个活动,当我回到同一页时,编辑文本的数据正在清除,我不想清除数据,如果我移动到另一页,有人能告诉我怎么做吗写下面的代码 if(PresetQuestion.value=="true") { String note1=note.getText().toString(); note.setText(note1); } 但

大家好,朋友们,我的程序中有编辑文本,如果我在上面写了一些东西,如果我正在点击其他选项,它将移动到另一个活动,当我回到同一页时,编辑文本的数据正在清除,我不想清除数据,如果我移动到另一页,有人能告诉我怎么做吗写下面的代码

    if(PresetQuestion.value=="true")
    {
        String note1=note.getText().toString(); 
        note.setText(note1);
              }

但我做得不正确也没关系…

在转到另一个活动时,如果您希望编辑文本显示以前输入的数据,则在转到另一个活动时不应
finish()
您的活动。
如果您对上一个活动
finish()
有此类要求,则应使用共享首选项保存日期,如下所示:

//decleration
SharedPreferences sp;
SharedPreferences.Editor ed;
//onCreate
  sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
  ed = sp.edit();
String edittextvalue=sp.getString("edtvalue", "");
if(!edittextvalue.equalsIgnoreCase(""))
  {
  edittext.setext(edittextvalue);
  }
save.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
    String editvalue=edittext.getEditableText().toString();
    ed.putString("edtvalue", edtitvalue);
    ed.putInt("check", 1);
    ed.commit();
//start New Activity
  } 
 });

使用
onSaveInstanceState(Bundle outState)
onRestoreInstanceState(Bundle outState)


第一个参数是首选项名称,另一个是它的默认值,我需要传递什么值??
@Override
    public void onSaveInstanceState(Bundle outState)
    {
        EditText edttext=(EditText) findViewById(R.id.textone);

        outState.putString("textone", edttext.toString());
    }
    @Override
    public void onRestoreInstanceState(Bundle outState)
    {

        String strval=outState.getString("textone");
        EditText bddb=(EditText) findViewById(R.id.textone);
        bddb.setText("prvvalue");
        ///outState.putString(""+idtext+"", bddb.toString());
    }