HOW to distribute a SQLite Database File with your app??

hello all,

Please tell me this is possible, I would hate to have to create / import all these records.

I have a nice trivia app 90% complete ( soon to be released ) that I have created and my daughter and her friend have created a SLEW of trivia questions for it.

they are all in a SQLite DB file and i was wondering how I can distribute the file?

Will it get compiled and installed automatically because its in the application folder when I compile the app?

And if so do i need to copy it to the … system directory before I can use it??

Or am I going to have to embed these in a local collection and then dynamically create / load the database and tables for my app ( which i do for the scores DB already ).

Please help.

Thanks

Larry Meadows
DoubleSlashDesign.com [import]uid: 11860 topic_id: 13711 reply_id: 313711[/import]

Hey Larry!

Check the conversation over here for details:

http://developer.anscamobile.com/forum/2011/03/03/sqlite-db-file-location

But short answer to the question is you can drag an existing SQLite DB directly into your main directory and read from it. HOWEVER, one caveat, you can’t do any alterations to it, it’s ‘read only’. If you want to INSERT or UPDATE any records, you’ll have to copy it over to the system.Documents directory.

Seriously, check out that link! We went through this a few months back (and I haven’t tried it yet) but seems to answer your question with great detail.

Holler if you have any more questions!

-Mario [import]uid: 11636 topic_id: 13711 reply_id: 50345[/import]

Thanks for the info, yeah I was using and testing it locally in my system.Documents folder in the simulator.

But the Trivia DB I would like to keep for Read only access. The users scores db I create dynamically in the system.Documents folder and that works fine.

I’ll copy the DB to my folder before I compile my APP, and change the code to look for it there on the device.

If I have any issues I could always copy it to the system.Documents.

thanks for the help… I’ll give it a try this afternoon.

Larry
DoubleSlashDesign.com

[import]uid: 11860 topic_id: 13711 reply_id: 50446[/import]

Question. If I wanted to backup the database to itunes file sharing or dropbox, could I do that?

Also what would the restore sequence be like?
1: Get the database
2: Copy the database to the main directory?

Thanks for your advice. [import]uid: 8192 topic_id: 13711 reply_id: 52102[/import]

That’s not what I meant.

I meant click a button in the app.
Save the database for itunes file sharing

and

Click a button
Restore the database from the db file that was stored in itunes file sharing.

Here is some info on File Sharing

http://developer.anscamobile.com/forum/2010/08/25/uifilesharingenabled-available-buildsettings

Thanks for your reply. [import]uid: 8192 topic_id: 13711 reply_id: 52111[/import]

Dang! That link is AWESOME. I guess it IS possible!

As far as your process of the restore, yeah you seem to be on the right track.

Um…not sure how to actually save out a SQLite DB to the filesystem. Um, did SQLite have a COPY_TABLE or EXPORT_TABLE function (sorry, it’s been a while and that might not be the right terminology)??

Anyone from Corona with some SQLite Kung Fu wanna chime in here? This is an excellent topic.

Thanks again for that link allowing filesharing. That saves me a TON of work!!! [import]uid: 11636 topic_id: 13711 reply_id: 52127[/import]

Your welcome. If you come up with a good process to do what I was wondering about, let me know.

I will be looking into dropbox as well, but filesharing is a great start for backup. [import]uid: 8192 topic_id: 13711 reply_id: 52129[/import]

[edit] Clarified below by original poster.

-Mario [import]uid: 11636 topic_id: 13711 reply_id: 52106[/import]

Accessing my DB in main directory worked like a champ.

Then I create a scores db in the system directory.

Works Flawlessly.

thanks for the assist.

Larry

DoubleSlashDesign.com [import]uid: 11860 topic_id: 13711 reply_id: 52185[/import]