Shared Preferences reset when the app is force closed or crashes

拜拜、爱过 提交于 2019-11-28 13:25:52

After some digging around I finally discovered the source of the problem. Through an error in my code, a string preference was getting saved with a null key. So after the crash when it went to load the Preferences there was a blank in the preferences xml file which caused the preferences to crash and be reset. For some reason I was not getting the stack trace of the preference crash, only the immediate cause of the initial crash.

Just to add some more details in case someone else has a similar problem in the future:

The xml file that has the preferences stayed intact up to and through the force close button press. The next time the shared preferences were accessed however, the xml file was cleared and started anew.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!