SQLite DB file remains after uninstalling the app

99封情书 提交于 2020-05-16 02:24:20

问题


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

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