开发者

How to create sqlite database within bundle during iPhone runtime?

I've tried using sqlite3_open statement, but the database is created at root level of my hard disk.

I can actually try to copy it to the bundle document folder. But,

  1. Where will the database created if I execute it during the iPhone runtime? (Since I use iOS Simulator, it is created on root level).

  2. How to create the database at the documents folder level immediately?

开发者_开发百科I'm sorry if I can't make myself clear enough, I'm really new working with database and stuffs.

Thank you for your attention.


You can not write to the main bundle, because it is signed with SSL certificate. But you can write to the document directory. Have a look at this link of how to create database at runtime in documents directory - create sqlite db programmatically in iphone sdk


You should create database file template with no content, but with structure, that you plan to use in your app. Add this template to your project Resources folder. Then, when app started, copy that file to Documents folder and use it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜