如何确保 sqlite DB 在应用程序更新期间得到更新?
我在应用程序商店中有一个由数据库驱动的应用程序,这意味着所有内容都驻留在 sqlite 数据库文件中。现在,我需要发送应用程序的另一个更新,并在 sqlite 数据库中更新一些内容,那么,确保我的数据库在应用程序更新期间得到更新的最简单方法是什么。请注意,它是静态应用程序,并且不包含同步数据库的在线服务,因此我正在寻找简单的东西,不涉及服务器端服务等。等待响应。感谢您的考虑。
I have an application on app-store which is DB driven, mean all the content is residing in the sqlite DB file. Now, I need to send another update of the app with some content update in the sqlite DB, so, What's the simplest way to make it sure that my DB gets updated during app update. Note that it's static app and there's no online services included to sync DB so I am looking for something simple, without involvement of server side services etc. Awaiting response. Thanks for your consideration.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果将数据库复制到 Caches 文件夹等位置,则应向数据库添加一个额外的表,其中包含数据库版本的条目。将诸如
2011-11-23
之类的内容作为字符串或日期添加到“db_version”条目中。当您更新数据库时,请更新该字段。当您的应用程序启动时,根据复制的数据库检查数据库的应用程序包版本。如果应用程序包版本较新,请在删除旧版本后复制它。如果从应用程序包中使用数据库文件而不进行复制,则无需执行任何操作。当应用程序更新时,旧版本将被删除。
If you make a copy of your database to somewhere like the Caches folder, you should add an extra table to the database with an entry for the database version. Add something like
2011-11-23
as a string or date to a "db_version" entry. When you update the database, update that field. When your app starts, check the app bundle version of the database against the copied database. If the app bundle version is newer, copy it after deleting the old one.If the database file is used from the app bundle without being copied, you don't need to do anything. The old version will be deleted when the app is updated.