简体   繁体   English

如何更新资产文件夹中的Sqlite数据库,而不是副本数据库?

[英]How to update Sqlite DB in asset folder, not the copy DB?

I need to deal with sqlite db placed in asset folder in Android project. 我需要处理放置在Android项目资产文件夹中的sqlite db。 The issue is that usually we create a copy of asset db at runtime and all the queries are done on this copy, but the problem is that when I clear the cache it will remove all updates; 问题是通常我们会在运行时创建资产db的副本,并且所有查询都在该副本上完成,但是问题是,当我清除缓存时,它将删除所有更新。 so I need to update the asset file not the copy that has been created on runtime. 因此,我需要更新资产文件,而不是在运行时创建的副本。

Can I insert update delete the asset sqlite file? 我可以插入更新删除资产sqlite文件吗?

Actually I want to preserve modifications on DB, and I don't want to loose these changes when clearing application data from settings. 实际上,我想保留对数据库的修改,并且在从设置中清除应用程序数据时,我不想放弃这些更改。

You CANNOT modify resources (assets, raw, drawable, etc.) of an .apk once its built. 一旦它内置您不能修改的apk的资源(资产,原料,绘制等)。 They are read-only , so what ever goes-in will always remain as it is - until you update the .apk with the newer stuff. 它们是只读的 ,因此任何输入内容都将始终保持不变-直到您使用较新的内容更新.apk为止。

You can not get the old record once you cleared the cache, and cant even update the asset file, once the apk file is generated as it is READ-ONLY . 清除缓存后,您将无法获取旧记录;一旦生成了apk文件,它就无法读取 ,甚至无法更新资产文件。 Yeah if you want assistance on how to use already ready database then this link will help you for sure. 是的,如果您需要有关如何使用已经准备好的数据库的帮助,那么此链接将为您提供一定的帮助。

Using your own SQlite Database in android applications 在Android应用程序中使用自己的SQlite数据库

And i think if you can copy database from assets folder, then, you can get it from sdcard too. 而且我认为,如果您可以从资产文件夹复制数据库,那么您也可以从sdcard获取它。 dont know much about it. 对此了解不多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM