卸载时未清除SharedPreferences [英] SharedPreferences are not being cleared when I uninstall

查看:509
本文介绍了卸载时未清除SharedPreferences的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这是一个奇怪的事情,我什至认为不可能.

OK, this is a strange one that I didn't think was even possible.

因此,自从我使用Nexus 5X以来,在卸载应用程序时,SharedPreferences不会被擦除.

So, ever since I've been using a Nexus 5X, the SharedPreferences are not getting wiped when I uninstall my app.

我通过Android Studio安装该应用程序并进行了测试.然后,我卸载该应用程序.然后,我通过Android Studio打包应用程序,所有SharedPreferences值仍然存在.

I install the app through Android Studio and test things. I then uninstall the app. I then resintall the app through Android Studio and all the SharedPreferences values are still there.

除了卸载之外,我还尝试清除数据/缓存.在所有这些尝试中,SharedPreferences都是持久的.

I've tried clearing the data/cache in addition to uninstalling. The SharedPreferences are persistent through all those attempts.

我正在Nexus 5X上使用现有的Android 6.0.我的设备未植根.我没有使用自定义ROM. Nexus 4没有这个问题.

I am using stock Android 6.0 on a Nexus 5X. My device is not rooted. I am not using a custom ROM. I do not have this issue with my Nexus 4.

任何想法可能是什么原因造成的?

Any ideas what might be causing this?

推荐答案

这是棉花糖的新功能.

This is a new marshmallow feature.

添加android:allowBackup="false"标记以禁用此行为.

Add android:allowBackup="false" tag inside your <application> object in your app manifest to disable this behaviour.

如果android:allowBackup标签与您正在使用的任何其他库冲突,则还应该添加tools:replace="android:allowBackup".

If android:allowBackup tag clashes with any other library you are using, you should add tools:replace="android:allowBackup" also.

这篇关于卸载时未清除SharedPreferences的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆