From 5785c3fcdd24c74fd795971172153c3dcafd7b33 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 30 Sep 2016 14:58:30 +0800 Subject: [PATCH] use SharedPreferences.apply() instead (#16632) --- .../java/src/org/cocos2dx/lib/Cocos2dxHelper.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java index db87c71c01..6ae9fb6a39 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -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)