Data file, what is the best place?

lufo88lufo88 USMember ✭✭✭


I need to add to my app a little db in sqlite. This file must be read at the first run of the app and reuse if the user clean the data of the app.
I guess I can put it in Resources folder, but I found this document by apple
"Moving data, such as long strings, or tables, out of code and into external files "
But they don't explain what they mean with "external files". How can I put the tables in the external file?



  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    The document you linked doesn't really apply to your question. You've already got an external file - the little db. That file will get compressed in the app bundle, so it should be pretty small.

    For the actual working db, what you would do is:

    At application startup, check for existence of the DB in the target directory (usually some place under Documents or LocalApplicationData or similar). If the DB file doesn't exist at that location, copy the seed DB from where ever it is in your app bundle (e.g. Resources) to that location. When you're app needs to open the DB, open it from the target directory.

  • lufo88lufo88 USMember ✭✭✭

    Thanks. :-)

Sign In or Register to comment.