I am currently building an iPhone app that is using Core Data and sqlite databases where the user will be reading static information from the database throughout the app. I have the issue where we may update the information in the database but not want to do a full update of the app, just the database. Can someone please help me out with either a easy function or a tutorial of how to go to a website or server and download the file which will replace the database that we have already put into the app? I'm new in xcode and I`m doing my first app.... thanks for your help
2 Answers
I think what would be a good idea is for your website to publish the data that must be stored in sqllite over REST, possibly in JSON or XML format.
This blog post describes how you could do just that. I must say that its approach to retrieving the content from the webservice is kind of low-level but it'll get the job done. Maybe RestKit can help you take care of all the low-level networking/http stuff.

- 5,645
- 3
- 34
- 35
-
I'm guessing they want to enable offline since they store locally. Always retrieving static data over rest would require constant connectivity. So if they store locally, could be a DB. Another option is to request from REST and store in file etc... bt that depends on how complicated the static data is. – bryanmac Sep 17 '11 at 14:24
-
Well yes it would be implemented in such a way that the sqllite db only gets refreshed every x period of time. that is a different issue, or is at least not apparent in the question – Hans Westerbeek Sep 17 '11 at 14:35
-
really is static data locally I don't require a constant internet connection for the app to work. I would like to update the SQLITE every certain period of time across another sqlite file or a xml hosted at a web server. thanks for your help!!!! – Alvaro Valenzuela Sep 20 '11 at 22:39
-
Alvaro... at stackoverflow, when people answer your question and they are useful you should upvote their answer. Finally, you should one mark the most useful one as 'the' answer. – Hans Westerbeek Sep 21 '11 at 08:40
I assume you want the static data locally so you don't require a constant internet connection for your app to work. Another option is to request the static data from the web and persist it in a file (NSUserDefaults etc...). But, that depends on how complicated the static data is and whether you have to query into that data. If you need to issue queries on that static data, a DB is definitely better.
You can also do a combination where you download updated DB if available async while your app works. You could have a setting in user defaults which is the current static data DB. If updated, you switch the current setting and re-establish the DB connection under a lock.
Here's how to make an http request using iOS.
If you're downloading db data, don't convert the NSData to a string like in that sample ...
Also, ASI-HTTP-Request is popular. Here's samples on how to download a file:
-
really is static data locally I don't require a constant internet connection for the app to work. I would like to update the SQLITE every certain period of time across another sqlite file or a xml hosted at a web server. thanks for your help!!!! – Alvaro Valenzuela Sep 20 '11 at 22:38