UPDATE 11/18/2011
Check the accepted answer. It works and its a life saver!
Hey everyone… so Im trying to figure out how to do this. I have bounced around alot of forums to try and find my answer, but no success. Either their process it too complicated for me to understand, or is just overkill. What I am trying to do is this. I have an XML file within my app. Its a 500k xml file that i dont want the user to have to wait on when loading. SO… I put it in my app which kills the load time, and makes the app available offline. What i want to do is, when the app loads, in the background (seperate thread) download the SAME xml file which MIGHT be updated with new data. Once the xml file is complete, i want to REPLACE the xml file that was used to load the file. Any suggestions or code hints would be greatly appreciated. Thanks in advance!
I ended up figuring this out. Its an old post but it appears to be getting alot of views still so I thought I’d help some people out. Keep in mind this code is NOT perfect… there are many ways to skin a cat.. and this is how I skinned mine. It works, thats all that matters!
In a nutshell how it works is…
The app launches > checks to see if there is a saved “date/ID”. It will be in the format of “MMDD”. If there is not a saved date/ID it will create a blank one to compare later.
When it compares if the id doesnt match, it will download a new file.
Todays date is 11/18/2011 so the ID would be “1118”. If you launch the app again today, the IDs will match so the app will parse the local xml file instead of downloading another one. (its a huge time saver for me, my XML file is 2-4 mbs.)
This code will download a new xml file daily, UNLESS the app has already been ran for the day. Then it will use the local file.