android– 在用户卸载应用程序时未删除SharedPreferences

android– 在用户卸载应用程序时未删除SharedPreferences,第1张

概述有没有人在Nexus6P设备上遇到过这个问题?我只是在Nexus6P(运行GoogleFi)上遇到此问题.当我安装应用程序时,在SharedPreferences中有一个用于userIsLoggedIn的键.这个块:booleanuserIsLoggedIn=SharedPrefs.userIsLoggedIn(this);//Theninanotherclass...publics

有没有人在Nexus 6P设备上遇到过这个问题?我只是在Nexus 6P(运行Google Fi)上遇到此问题.

当我安装应用程序时,在SharedPreferences中有一个用于userIsLoggedIn的键.

这个块:

boolean userIsLoggedIn  = SharedPrefs.userIsLoggedIn(this);// Then in another class... public static boolean userIsLoggedIn(Context context) {    // For users updating apps, if the prevIoUs key-value is a string, convert it to boolean    try {        return context.getSharedPreferences(LOGIN_file, Context.MODE_PRIVATE)                .getBoolean(USER_LOGGED_IN, false);    } catch (ClassCastException e) {        Logger.e(TAG, e.getMessage());        context.getSharedPreferences(LOGIN, Context.MODE_PRIVATE)                .edit()                .putBoolean(USER_LOGGED_IN, false)                .commit();        return context.getSharedPreferences(LOGIN, Context.MODE_PRIVATE)                .getBoolean(USER_LOGGED_IN, false);    }}

现在这应该在新卸载时返回false但在全新安装上调试它我在App Startup上得到以下内容.

我也运行Proguard,如果这很重要,当在非proguard启用的APK上运行设备时它运行正常.在任何其他设备上运行proguard运行正常.

解决方法:

由于Nexus 6P运行的是AndroID M,我认为Automatic Backups就是问题所在.

我想你可以用allowBackup来阻止它.

检查这个答案:https://stackoverflow.com/a/32010582/336312

总结

以上是内存溢出为你收集整理的android – 在用户卸载应用程序时未删除SharedPreferences全部内容,希望文章能够帮你解决android – 在用户卸载应用程序时未删除SharedPreferences所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1102073.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存