New Database sqlite not updated when deployment (emulator or device)
Hi
I put the sqlite database inside the resource folder and it seems to get copied into the emulator or actual device.
But when I made some changes to the sqlite file and I try the emulator or device launch again, it seems like the old database is not being replaced because I get errors accessing new data.
It only work after I manually delete the App from the device or emulator.
Is there a way to resolve this issue?
4 Answers
-
Accepted Answer
The problem is that the iPhone simulator is caching the SQlLite db so you need to restore the simulator settings(iPhone simulator/initialize content and settings) everytime you make changes in your db in order to be able to notice the changes.
Hope this helps. -
Yes, there is.
You can do this by giving your database a new name when installing it. The easiest thing would probably be to append a version variable to the name and then update this on database changes:var dbVersion = 1.0; Ti.Database.Install('mydatabase.sqlite', 'mydatabase' + dbVersion);
Cheers
-
I've done this but now i have a strange problem where it works fine on my simulator but doesn't update the database on my device, even if i delete the app then reinstall. How is it caching the database when I am using versioning as well as deleting the app?
-
Hey Ben,
I'm thinking that you could use something similar to this:
Titanium.Database.DB.remove Ti.Database.Install('mydatabase.sqlite', 'mydatabase' + dbVersion);
Based on this, I think only the previous database will be destroyed (the DB that's in app-memory)
Let me know how it goes
-R