问题
I have a flutter app where I use a sqflite DB storage. I create a DB as pointed in the sqflite example - I use getDatabasesPath()
as a relative path to the app and then var db = await openDatabase(path_to_db_file);
. Everything works fine, I can create tables, work with data and so on.
I face a problem when I uninstall the app. While still in development I need to add more tables, purge data, change column names, etc. I want after I uninstall the app, to delete all the files associated with it and on the next install (debug session) start fresh. This works on some devices. There are cases where after uninstalling the app some files remain. The DB file remains. And when I install the new version with expected DB changes, they don't work against the database file that has remained undeleted.
I would like to ask is there a mechanism to explicitly tell android to delete everything associated with that app upon uninstalling it?
回答1:
Some android phones auto backup data even when you uninstalled app, the data still comes back. This is what i've done in my app:
in AndroidManifest.xml:
<application
android:name=".Application"
android:allowBackup="false"
android:fullBackupOnly="false"
above 2 backup properties to false
来源:https://stackoverflow.com/questions/60827392/sqlite-db-file-remains-after-uninstalling-the-app