rkb
rkb

Reputation: 11231

Where does the sqlite database for iPhone is stored with the application

I want to know when we install an application where does the database of the application resides. Like Does it resides in the application bundle or sandbox.

Also when we upgrade it why does not it affects the existing database. For example, if I make some changes to database table and reinstall it, it still uses the previous table. So how does it actually works at the background.

Upvotes: 2

Views: 914

Answers (1)

invalidname
invalidname

Reputation: 3185

You choose the location by providing a path to a db file when you call sqlite3_open. The path should almost certainly be to a file in your Documents directory, since any place else either won't be backed up (tmp) or won't be accessible (the app bundle, or paths outside your sandbox).

Since you manage the file, you could also create a .db file on your computer with the default database contents, put that in your app bundle, and then copy it over to Documents the first time your app comes up and finds no file in the expected location.

Upvotes: 3

Related Questions