Pre-populate iPhone Safari SQLite DB
Posted
by Matt Rogish
on Stack Overflow
See other posts from Stack Overflow
or by Matt Rogish
Published on 2010-06-14T01:11:06Z
Indexed on
2010/06/14
1:22 UTC
Read the original article
Hit count: 274
I'm working with a PhoneGap app that uses Safari local storage (SQlite DB) via Javascript:
On first load, the app creates the database, tables, and populates the data via a series of INSERT statements.
If the user closes the app while this processing is happening, then my app database is left in an inconsistent state.
What I prefer to do is deploy the SQLite DB as part of my iTunes App packaging so nothing must be populated at app cold start. However, I'm not sure if that is possible -- all of the google hits for this topic that I can find are referring to the core-data provided SQLite which is not what we're using...
If it's not possible, could I wrap the entire thing in a transaction and keep re-trying it when the app is restarted?
Failing that, I guess I can create a simple table with one boolean column "is_app_db_loaded?" and set it to true after I've processed all my inserts. But that's really gross...
Ideas? Thanks!!
© Stack Overflow or respective owner