Updating SQLite database with MySQL database based on version
This is my first post here so I’m going to do my best to ask my question in the best possible way. I wouldn’t be here asking if I had other options.
First off I am basically new to iPhone development. I am currently working on an app which has a great working version on the app store, but now it’s time for some updates. A basic description of the app is that it is an informational app. Users get it to find out information about certain things. The one that’s currently up is basically static. All the information is stored in a sqlite database and is pulled from this database for the users to view. It’s nothing special at all, just sitting in the apps resource folder which we all know is not editable.
The version that we need to update it with is completely dynamic. I built a webservice with a MySQL database with feeds for the information that gets updated. This all works great. When the app starts it deletes the existing database in the Documents directory and then recreates it based on the schema of the database in the Resources directory. I can perform an update on the web side and the app updates as it should, which was a task in itself…lol
Here is where my problem lies. I don’t want to go through this process every time because the information is a bit heavy and only going to be added to, but not frequently. So ideally I would like the database to be updated on the first run, but not again until the data has changed in the database, maybe weekly or so. I would like to accomplish this using a database version table, stored on my webservice side and the app side. I have the tables built to hold the versions but I can’t figure out how to compare the two. I.E. The MySQL database has a version of 1, so does the SQLite database, so nothing happens. Now the MySQL database has a version of 2 and the sqlite is still 1, so the sqlite database in the Documents directory gets deleted and the new one gets brought in, parsed and put in to the sqlite database in the Documents directory.
All the work as far as the parsing and inserting is being done in the AppDelegate. I’m not too sure how to accomplish what I am trying to do. I have done an ample amount of research on this and I do find things that say that this is one way to do it along with last modified date, but that is about it. I would really like to stick with the database version way as that is what I am currently setup for. If someone can point me in the right direction for this I would greatly appreciate it. If any more details are needed please ask…
|