SachinKS 于 2013.06.21 11:34 提问
- SharedPreferences重写其它值
-
有一个问题关于
SharedPreferences
,如果要保存两个不同的值,代码:SharedPreferences sharedPref = getSherlockActivity().getPreferences(Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt(getString(R.string.SavedStartSilentHour), hour); editor.commit(); editor.putInt(getString(R.string.SavedStartSilentMinute), min); editor.commit(); // One editor.commit() is enough
但是第二个值会覆盖第一个值。如果删除第二部分,保存就正确。为什么?