Adam Paul
Adam Paul

Reputation: 35

Files in internal storage "getFilesDir()" are not being deleted when app is uninstalled

Title pretty much says it all.

I created files in internal storage with the path from getFilesDir() with the idea that they should be deleted when the app gets uninstalled. But they are not being deleted at all.

If I want to delete the data I have to do it manually in my phones applications settings, or manually delete the files out with the device file explorer in Android Studio. This is not ideal.

Can anyone help?

Upvotes: 1

Views: 1019

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007564

There is an android:allowBackup attribute available for <application> that controls whether the app's data can be backed up automatically by the OS. If this attribute is set to true and the app is reinstalled, a backup of its data is restored. During development, this can be a pain. And, in production, neither you nor the users have much control over the backup process.

If you wish to disable this — for debug builds or all builds — set android:allowBackup="false" on <application> in the appropriate edition of the manifest (e.g., src/main/ for all builds, src/debug/ for debug builds).

Upvotes: 2

Related Questions