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
如果我运行此代码,则第一个值将被第二个值覆盖。如果我删除第二部分,则值将正确保存。这是为什么?