I'm looking to update my app database with a newer version on a webserver.
Now im not sure what the best approach is. I have already made the decision to do it over a wifi connection as the new iPhone contracts in the UK are no longer unlimited data. Therefore I don't want people updating using there allocated amount of month data usage.
SO with that decision made, I'm looking to checking if a new database is available and they have a wifi connection. Then downloading the new database to replace the existing one on their iPhone.
Should i create a safety net by renaming the old database and renaming the new one to the correct name in case the connection drops. Then if the connect is broken revert back to the old database so there app still works?
Any thoughts or guidance about this would be great. Especially if anyone has done something similar.
Thanks in advance my friends
The flow I would follow would be:
- add the db to the project & a hash code to app.properties
- query the server to see if there's a new version, passing the hash code
- Server responds with a HTTP 304 if there's no change, otherwise HTTP 200, a header with the new hash & the database
- hash the downloaded db and compare against the header hash
- if both are the same - then the download was ok.
- Close the connection to the DB if open
- Rename the old db
- Rename & move the new db to the right place.
- Update the stored hash with the new value.
- Open the DB again.
- If both hashes aren't the same - there was an error.
- Log the issue & inform the user
thank you for your quick reply! WOW! I think I will be reading and learning more about those suggestions tonight rather than developing :)
I really value you response and thank you.