+1
Answered

Can I make an action to download an XML file, then reference it locally until I redownload it?

thillsman 12 years ago updated by icahill (Administrator) 12 years ago 2
I'm not sure if my title makes sense. Here's my problem: I'm using a few server-hosted XML files and querying them multiple times within each session of using my app. And this is working fairly well, but it always takes a noticeable amount of time (especially on 3G) to populate my lists.

Here's what I want to do: take a little bit of time to download the XML file to my app when the app opens (or force it through a user-activated action) and then query it locally for the duration of the app session. Ideally, I'd like the app to copy the XML file to a local file and then have my datasources reference these local files (similar to how Pixel Artist creates images with < create> and references them to display them later).

So... Can I do this?
Can you use Settings-> App Settings --> Cache Duration ?

This applies globally to your app so it should be an easy fix if you don't have other parts of your app that need to be downloaded more often.

Cache Duration (above) will suffice in storing previously downloaded content from a datasource for a specified amount of time. This is mainly meant for times when your device is not near an internet connection.

Another solution that might work for you and one which will be available in version 1.4 of the WIRE engine (i.e. the next iteration). Is the use of a download action tag. This wil allow you to save your XML file to your App contents and then you can use it like any other on board asset.



<action name="download">
<download progresstarget="PBAR" downloadcomplete="loaded-xml" filename="documents/table.xml" url="http://where.xml.is.hosted.com"/>
</action>
<action name="loaded-xml">
Now use the table.xml that is now saved into your app to do what you need to do.
</action>


If you are interested in this, I can find out the timeline for 1.4 and let you know. Any questions about this I can also answer here.

Thanks.