1
votes

I have an app that generates some static data by importing from a json file into a sqlitedb, When running the app the DB file has data in it and is loaded properly, I usually go to the build folder "usually under

  /Library/Application Support/iPhone Simulator/7.0.3-64/Applications/

and inspect the sqlite file and verify that it does have data. Now I copy that same folder and paste it on the desktop, and open it in the same sqlite browser, and the data is gone?? why I don't know!! I notice that for every sqlite file there is a -shm and -wal file generated.

Why is this happening?

Ok so I tried a little bit more investigating, I have two scenarios :

1 : I put a break point right after I finished generating the SQLite file, and then go the build folder, In the build folder the DB has data in it, if I copy that file to the desktop the db loses its data.

2 : I don;t put a break point, let the app finish normally ( gracefully ) and then go to the build folder, the db file has data, and when I copy and paste it to the desktop it still retains the data.

So I assume there's something that happens when xcode exits ( or the app closes normally ) that I am missing out on when I put a breakpoint !!

1

1 Answers

3
votes

Starting with iOS 7 the sqlite database is used in Journaling mode by default - which means that all changes to the database are written to "update files", not to the database directly. You can change the behaviour back to the "old" way - have a look here for a complete explanation :

Core Data and iOS 7: Different behavior of persistent store