卸载应用程序后android保留数据库 [英] android keep database after uninstalling app

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

问题描述

我正在开发一个 sq-lite 数据库,我可以在其中找到三星设备中的问题.当我卸载应用程序时,android OS 保留导致数据库版本冲突的数据库 - 以前我使用版本 2,现在我使用版本 1 作为 sqllitehelper 构造函数中的参数.按照惯例,当应用卸载时,Android 操作系统会删除所有数据库、共享首选项和缓存文件.

我在应用程序文件夹中使用了数据库存储的默认位置.

这是我得到的错误:

<块引用>

Caused by: android.database.sqlite.SQLiteException: Can't downgrade database from version 2 to 1

解决方案

我在三星 S8 上遇到了同样的问题 - 显然在三星 Android 设备上,删除应用程序时不会自动删除应用程序内存.因此,当安装新的应用程序版本时,旧数据库仍然存在,如果数据库架构发生变化但数据库的版本号保持不变甚至减少,则会发生冲突.

解决方案:要安全删除数据库,您必须在系统设置的应用程序区域中打开受影响应用程序的详细视图.在这里,您可以显式删除数据(以及数据库)并清空缓存.之后,您可以删除该应用程序.下次您在三星设备上安装该应用程序时,将新建数据库.

I am working on an sq-lite database where I can find an issue in Samsung device. When I uninstall app android OS keeps database that cause conflicts in database version - previously I used version 2 and now I am using version 1 as a parameter in sqllitehelper constructor. By convention when app is uninstalled Android OS deletes all databases, shared preference and cache files.

I used default location of database store in app folder.

This is the error I get:

Caused by: android.database.sqlite.SQLiteException: Can't downgrade database from version 2 to 1

解决方案

I had the same problem on a Samsung S8 - apparently on Samsung Android devices the app memory is not automatically deleted when an app is deleted. Thus the old database still exists when a new app version is installed and there is a conflict if the database schema changes but the version number of the database remains the same or is even reduced.

Solution: To delete the database securely, you have to open the detailed view of the affected app in the app area of the system settings . Here you can explicitly delete the data (and thus the database) and empty the cache. After that you can delete the app. The next time you install the app on your Samsung device, the database will be newly created.

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

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