SharedPreferences sp = getSharedPreferences("atw",MODE_PRIVATE);//創(chuàng)建對象, String readstring = sp.getString("isFirst", "false");//默認false if (readstring.equals("false")){ SharedPreferences.Editor editor = sp.edit();//獲取編輯對象 editor.putString("isFirst","true");//keyname是儲存數(shù)據(jù)的鍵值名,同一個對象可以保存多個鍵值 editor.commit();//提交保存修改 }