Where to store header (last-modified) to compare file from server for download? Android

418 views Asked by At

I am pulling a file from the web and parsing it. I can get the last-modified header info in an async task like so:

URLConnection connection = null;
            try {
                connection = new URL(myUrl).openConnection();
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println(connection.getHeaderField("Last-Modified"));

It gets the data. I want to save this Last-Modified date and then do a check the next time the myUrl request is made and download if a change, else not download.

Where should I store this Last-Modified date in order to do the comparison later when the request for the url comes and how would I go about it?

Write data to a file on internal storage? in memory? Just drawing a blank on the quickest way to store and compare.

1

There are 1 answers

3
Michael Hampton On

Don't bother. Just add an HttpResponseCache and let Android worry about it. (Requires API level 13)