Browse Source

1.将CurrentAppSharedPreferencesUtils中的apply修改为commit防止应用退出时,文件写入失败。

20241218TB223FC(测试jar包)
wangwanlei 4 months ago
parent
commit
9568915a41

+ 3
- 3
app/src/main/java/com/xhly/manageapp/utils/CurrentAppSharedPreferencesUtils.java View File

60
             editor.putLong(key, (Long) object);
60
             editor.putLong(key, (Long) object);
61
         }
61
         }
62
 
62
 
63
-        editor.apply();
63
+        editor.commit();
64
         return false;
64
         return false;
65
     }
65
     }
66
 
66
 
103
         SharedPreferences.Editor edit = preferences.edit();
103
         SharedPreferences.Editor edit = preferences.edit();
104
         if (edit != null) {
104
         if (edit != null) {
105
             edit.putString(key, strJson);
105
             edit.putString(key, strJson);
106
-            edit.apply();
106
+            edit.commit();
107
         }
107
         }
108
     }
108
     }
109
 
109
 
111
         SharedPreferences.Editor edit = preferences.edit();
111
         SharedPreferences.Editor edit = preferences.edit();
112
         if (edit != null) {
112
         if (edit != null) {
113
             edit.putString(key, "");
113
             edit.putString(key, "");
114
-            edit.apply();
114
+            edit.commit();
115
         }
115
         }
116
     }
116
     }
117
 
117
 

Loading…
Cancel
Save