我想在我的 android 应用程序中保存大约 30 个字符串数据,但有时在内存几乎已满的 android 手机中,会出现此错误:
致命异常:在 com.android.internal.util.FastXmlSerializer.(FastXmlSerializer.java) 在 com.android.internal.util.XmlUtils.writeMapXml(XmlUtils.java:177) 在 android.app.SharedPreferencesImpl 的 java.lang.OutOfMemoryError。 writeToFile(SharedPreferencesImpl.java:596) at android.app.SharedPreferencesImpl.access$800(SharedPreferencesImpl.java:52) at android.app.SharedPreferencesImpl$2.run(SharedPreferencesImpl.java:511) at android.app.SharedPreferencesImpl.enqueueDiskWrite(SharedPreferencesImpl .java:532) 在 android.app.SharedPreferencesImpl.access$100(SharedPreferencesImpl.java:52) 在 android.app.SharedPreferencesImpl$EditorImpl.commit(SharedPreferencesImpl.java:454)
在 sharedpreference 中保存大约 30 个字符串仍然很好吗?
我从这里读到不要为每个更改创建一个新的编辑器,也许我必须更改一些调用新编辑器的字符串更改,这对防止 java.lang.OutOfMemoryError 有很大的贡献还是我必须做其他事情?