卸载应用程序后,SQLite DB文件仍然保留 [英] SQLite DB file remains after uninstalling the app

查看:637
本文介绍了卸载应用程序后,SQLite DB文件仍然保留的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Flutter应用程序,在其中使用sqflite数据库存储.我按照sqflite示例中的说明创建了一个数据库-我将getDatabasesPath()用作应用程序的相对路径,然后使用var db = await openDatabase(path_to_db_file);.一切正常,我可以创建表,使用数据等等.

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.

我想问问有没有一种机制可以明确告诉android在卸载它时删除与该应用程序关联的所有内容?

I would like to ask is there a mechanism to explicitly tell android to delete everything associated with that app upon uninstalling it?

推荐答案

即使您卸载了应用,某些Android手机也会自动备份数据,但数据仍会返回.这是我在应用程序中所做的:

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:

在AndroidManifest.xml中:

in AndroidManifest.xml:

<application
    android:name=".Application"
    android:allowBackup="false"
    android:fullBackupOnly="false"

将2个备份属性设置为false

above 2 backup properties to false

这篇关于卸载应用程序后,SQLite DB文件仍然保留的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆