private SharedPreferences preferences;
preferences= getSharedPreferences("user", Context.MODE_PRIVATE);
在满足条件试进行记录
SharedPreferences.Editor editor=preferences.edit(); editor.putString("age", "iiiii"); editor.commit();再次打开activity时,会走onResume(),进行数据的取值
String name=preferences.getString("age", ""); if (name!=null&&!"".equals(name)){ startActivity(new Intent(MainActivity.this,SearchActivity.class)); }