views:

132

answers:

2

My app has a SQLite database that users can read only. I, the developer, would like to add entries to the database from time to time and make the enlarged database available as a file on a Web server. I'd like the users to be able to "check for updates".

My question is, once a user checks and finds that an updated DB file exists, how can/should the file be downloaded to the iPhone and written over the previous version of the DB?

Does the iPhone even allow files to be downloaded and saved?

+1  A: 

If you are connected to the SQLLite with CoreData it does not take kindly to having the storage ripped out from underneath it and replaced.

As you have a database then why not make use of the database features. To the user it is read only. To your app it can be updated. Make a HTTP request and download the updated data rows from the webserver in a suitably machine readable format, and update the data tables with that. You might even be able to just serve delta's of the data depending on what you are holding.

Kevin
The database should be quite small. I think it would be easier to just download the latest rather than update the existing. That raises an interesting question: if the DB were zipped, could the iPhone unzip it after downloading?
Scott Pendleton
Yes! http://code.google.com/p/ziparchive/
Eric Schweichler
+1  A: 

"Does the iPhone even allow files to be downloaded and saved?"

Yes, you can save files in your Applications Documents directory at run-time. The <Application_Home>/Documents/ is a good place, since the files stored in this location are preserved when the user does iPhone backups with iTunes.

More information on Where you can write to and how here: http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/FilesandNetworking/FilesandNetworking.html#//apple_ref/doc/uid/TP40007072-CH21-SW11

Eric Schweichler
Very helpful, thank you.
Scott Pendleton