use SharedPreferences.apply() instead (#16632)

This commit is contained in:
minggo 2016-09-30 14:58:30 +08:00 committed by GitHub
parent c046257efc
commit 5785c3fcdd
1 changed files with 6 additions and 6 deletions

View File

@ -620,21 +620,21 @@ public class Cocos2dxHelper {
SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean(key, value);
editor.commit();
editor.apply();
}
public static void setIntegerForKey(String key, int value) {
SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt(key, value);
editor.commit();
editor.apply();
}
public static void setFloatForKey(String key, float value) {
SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putFloat(key, value);
editor.commit();
editor.apply();
}
public static void setDoubleForKey(String key, double value) {
@ -642,21 +642,21 @@ public class Cocos2dxHelper {
SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putFloat(key, (float)value);
editor.commit();
editor.apply();
}
public static void setStringForKey(String key, String value) {
SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString(key, value);
editor.commit();
editor.apply();
}
public static void deleteValueForKey(String key) {
SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.remove(key);
editor.commit();
editor.apply();
}
public static byte[] conversionEncoding(byte[] text, String fromCharset,String newCharset)