Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
460 views
in Technique[技术] by (71.8m points)

android - SharedPreferences are not being cleared when I uninstall

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

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

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.

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is a new marshmallow feature.

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...