Database won't remove when uninstall the Android Application

五迷三道 提交于 2019-12-02 17:25:43

in Android 6.0, google added new feature called Auto Backup.

when this option is on(default is on), Android system copies almost every directories and files that created by system, and upload it to user's google drive account.

When user reinstalls app, android automatically restore app's data, no matter how it was installed(via Play store, adb install, initial device setup).

The restore operation occurs after the APK is installed, but before the app is available to be launched by the user.

android developers page : https://developer.android.com/guide/topics/data/autobackup.html

Michael.

I cam across this question when I was looking for a solution to a similar problem related to GreenDao - slightly more in depth answer here but basically if your on api 23 you'll need to set allowBackup to false to be able to depend on the databases being cleared when you uninstall

https://stackoverflow.com/a/43046256/5298819

If this is a personal account and you need to delete the backup for testing, you can go to drive.google.com for your account and navigate to the backups section.

Select a backup and you are given the option to delete the backups for a specific device:

robkriegerflow
  1. Take a look at this SO answer:

What happens to a Sqlite database when app is removed

  1. Does your DB work (aside from not deleting when removing the app)?

  2. If it isn't working properly, you may want to take a look at:

http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html

Although this is not necessarily related to your issue, you might want to consider creating an open() and close() for your DB and use a SQLiteOpenHelper object in each - in open(), you would use sqliteopenhelperObj.getWriteableDatabase() and in close() you would use sqliteopenhelperObj.close().

http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html#close

Edit:

  1. If you've downloaded files to your device during the process of testing an app, and you want to delete them, you can use the Device Monitor in Android Studio https://developer.android.com/tools/help/monitor.html There's a file manager that will allow you to see and edit files on your devices. You can also do this on the command line with the ADB (Android Debug Bridge) https://developer.android.com/tools/help/adb.html

The auto backup can be disabled by setting android:allowBackup="false" in AndroidManifest.xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!