Vitaly
Vitaly

Reputation: 61

How to force delete application data on uninstall (Android)?

There is a strange function in some Android devices (at least Galaxy S7): they restore data (for example the SQLite database) when the application is reinstalled. This behavior interrupts my app because the data is supposed to be deleted during uninstallation.

How can I force Android to completely delete all that data when the app is manually uninstalled?

Upvotes: 2

Views: 2868

Answers (3)

Arul
Arul

Reputation: 1179

It is a privacy concern. It is recommended to disallow users to backup an app if it contains sensitive data. Having access to backup files (i.e. when android:allowBackup="true"), it is possible to modify/read the content of an app even on a non-rooted device.

Solution - use android:allowBackup="false" in the manifest file.

Read this post to know more about this: https://resources.infosecinstitute.com/android-hacking-security-part-15-hacking-android-apps-using-backup-techniques/

Original post: https://stackoverflow.com/a/43475593/5304075

Upvotes: 1

Md. Asaduzzaman
Md. Asaduzzaman

Reputation: 15423

You have to disable the backup from AndroidManifest.xml

android:allowBackup="false"
tools:replace="android:allowBackup"

N.B: If you use any third party library that use android:allowBackup="true" then it conflicts and give error. To resolve this and override the setting you also have to add tools:replace="android:allowBackup".

Upvotes: 6

Gourav
Gourav

Reputation: 2819

For your question, it's simple. Just add the below line to your app's manifest file's <application> tag.

android:allowBackup="false"

This makes the app's data not to be saved when it is uninstalled.

Upvotes: 1

Related Questions