Artem Artem - 1 month ago 22
Android Question

How to remove SharedPreferences when I remove app on Android 6

When I delete app from a device with standard removing-methods (drag-and-drop for example) my

SharedPreferences
doesn't clean.

Why?

How to clean my
SharedPreferences
?

P.S. If I clear data in
Setting
manual
SharedPreferences
cleaned, but this isn't a solution for me.

Answer

How to clean my SharedPreferences?

What are you experiencing is the default behavior of allowBackup, whch is true by default. From the documentation:

Whether to allow the application to participate in the backup and restore infrastructure. If this attribute is set to false, no backup or restore of the application will ever be performed, even by a full-system backup that would otherwise cause all application data to be saved via adb. The default value of this attribute is true.

if you want to disable it add allowBackup="false" to the Application tag on your AndroidManifest. This way the SharedPreferences won't be restored