我創建SharedPreference OBJ使用下列內容: 注:在相同的首選項文件名創建喜好的數量android共享偏好存儲多個值;
public static Sting name = "abx"; //pref file name
spo = context.getsharedpreference(name , mode_private);
editor = spo.edit(); //get the editor associated with pref obj
Map<String, String> test= new HashMap<String, String>();//create a map
test.put("1", "abc");//fill the values
test.put("2", "efg");//used map because values are stored in key -value pairs
test.put("3", "ghj");
for (String s : test.keySet()) {
// use the name as the key, and the icon as the value
editor.putString(s, nameIcons.get(s));//use the key as preference name
}
editor.commit();//commit the preferences
我有一個疑問,請糾正我,如果我錯了,有名字SharedPreference文件「ABZ」是創建並在此文件中的首選項值存儲爲鍵值對,或者如果編輯器obj爲每個鍵創建新的首選項文件,在創建共享首選項對象時提供pref文件名的用法是什麼?