Arnold
Arnold

Reputation: 2420

Read-only SQLite database in application bundle

Assume I have bundled a large internal reference data SQLite database with my iOS application. It will never be written to at runtime and may only change with a new app release.

Generally, pre-generated SQLite database files would be copied into the app's Library or user Documents directory before being used, to allow read access. But since it's not required in this case: is there any harm, potential performance issue, or other problem with keeping the file in the app bundle and using it from there?

In other words:

let myBundledDatabase = NSBundle.mainBundle().pathForResource("MyDatabase", ofType: "db")!
sqlite3_open(myBundledDatabase, // ...

Upvotes: 1

Views: 311

Answers (1)

EricS
EricS

Reputation: 9768

This should work fine. Specify the SQLITE_OPEN_READONLY flag when opening the file and use sqlite3_open_v2(...).

Upvotes: 3

Related Questions