Actually, i am fetching XML from the web, parsing it and display it on the screen. The problem which i am getting is that the activity tries to load the data from web each time the activity is called.(Actually, my mobile app requires frequent trips to the server) So i am in search of the below solution:
On Re-launch of an activity, the data from web should not be loaded again.
creating a class that i can use to transparently make application faster by
selectively caching items in memory. And thus, making users very happy and
This class can even apply individual refresh times to each cached item.
So, i think i need to store the data in Cache or something like that.
Is there any way/technique to implement such thing ? so that it need not to load every-time on Re-launch of an activity.
Not sure what the performance would be with this suggestion, but the by far easiest if you just want to avoid fetching the XML files every time your activity re-launches, is to save them to Internal Storage. When your activity (re-)launches, you'll start by checking if the files exist locally before you fetch them from the web.
You would of course need come kind of logic to tell whether an XML file is "out of date" (you could have a simple database table with file names and last-fetched dates), and you would probably also like to have some kind of clean-up logic to delete files when you no longer need them so they don't fill up unnecessary space.