sayzlim
sayzlim

Reputation: 275

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.

Upvotes: 0

Views: 1379

Answers (2)

5hrp
5hrp

Reputation: 2230

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.

Upvotes: 1

saadnib
saadnib

Reputation: 11145

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

Upvotes: 1

Related Questions