I am working on an app that will be pulling data from a SQLite Db locally. The app is running file but as I am testing, I add more records and such but for some reason both the simulator and the Device only see the last copy.
I have done a CLEAN build, removed the .DB from the project and then added it back, but to no avail. If the DB has 5 records, I update/add two more records, those new records are not showing.
About the only way I can get them to be seen is to remove the .DB from project, rename the DB to another name, then add back.
I know this sounds like some type of cache issue but am unable to figure out how to clear it out. As I mentioned, does same for both simulator and device.
Any help is greatly appreciated. Thanks in advance.
Geo…
If you have a db file in your resources, you need to copy it from resources to either library or document on launch and then connect to the one in documents or library.
Hint: log out the path your connecting to, open that in terminal (it will be under Derived Data) and then connect and query using the sqlite3 cmd line (search). That helps keep you’re sanity that you’re operating on the right db and you can inspect your data as you go.
As a side note, see this post (I have a library which handles all this if you’re interested):
Don't wan't to replacing the old database when app is updated
Here’s an example from a sample app where I call ensureOpened (which handles the copy from resource and logs what I’m using):
Hope that helps