SharedPreferences sp = getSharedPreferences("atw",MODE_PRIVATE);//创建对象, String readstring = sp.getString("isFirst", "false");//默认false if (readstring.equals("false")){ SharedPreferences.Editor editor = sp.edit();//获取编辑对象 editor.putString("isFirst","true");//keyname是储存数据的键值名,同一个对象可以保存多个键值 editor.commit();//提交保存修改 }
时间: 2024-10-25 17:48:01