为什么重新安装 apk 后数据库会被删除?
我有一个与我开发的在蜂窝上运行的应用程序相关的问题。当我重新安装 apk 时,它的数据库被删除。大约 1 周前还没有这样的情况。为什么现在会发生这种情况?什么会导致数据库被删除以及如何防止它?
I have a problem related to the app that I developed which runs on honeycomb. When I reinstall the apk its database gets deleted. There did not used to be this almost 1 week ago. Why this is happening now? What can cause db to be deleted and how to prevent it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为,如果您的数据库存储在应用程序的内部存储
/data/data//databases/
中,那么当您的应用程序从设备中卸载时,包含应用程序包的所有目录都会被删除。从设备中删除这会导致您的数据库被删除。为了防止将您的数据库副本放在应用程序的
/asset
目录中,这样每当您的应用程序第一次运行时,它就会将数据库从资产复制到内部存储路径。每当重新安装应用程序时您都可以访问它,您也可以将数据库放在/sdcard
中,但用户也可以删除它。.编辑: 在 Android 应用程序中使用您自己的 SQLite 数据库 和 如何使用数据库发送 Android 应用程序?
谢谢。 ..
I think, If your database stored in application's internal storage
/data/data/<package_name>/databases/
then when your application un-installed from device, all directories with your application package are removed from the device this cause your database removed.To prevent put your database copy in application's
/asset
directory so whenever your application first time runt it copy the database from asset to internal storage path. And you can access it whenever application re-installed, also you can put your database in/sdcard
but user can also delete it..EDIT: Using your own SQLite database in Android applications and How to ship an Android application with a database?
Thanks...
我猜想是关于检查代码中现有的数据库。但我不确定,它可能由多种原因引起。给个想法吧。
i guess it about checking existing database in your code. but i'm not sure exactly, it can occur from many causes. Just give an idea.