开发者

Replace SQLite DB content when updating app [duplicate]

开发者 https://www.devze.com 2023-03-26 13:53 出处:网络
This question already has an answer here: Trying to over开发者_开发知识库write sqlite database in iPhone app update
This question already has an answer here: Trying to over开发者_开发知识库write sqlite database in iPhone app update (1 answer) Closed 2 years ago.

I have an iPhone app with a SQLite DB storing all the information similar to a book. The user only reads information off the DB and won't update it as the app does not allow update of data. When there is an upgrade, both the content of DB and the app are to be replaced. I want to know:

  1. What is the best way to handle an upgrade as I want to over-write the DB entirely with a new one.
  2. Actually I have now a new version pending review by apple and I have completely missed this issue. As this is my first iPhone application, I do not know what I can do to handle this situation. Can anyone help?


You can only alter files in a couple subdirectories of the application’s home directory. For a database file, you probably want the Documents directory (if it’s not already there at launch, just copy it from your app’s bundle), and then do a safe-replace (see NSFileManager). I do this exact thing in MediBabble.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号