Using ResponseCache in an Android App

Tuesday, 29 June, 2010 Posted in:

I’m currently working on an Android app and I’ve decided to use the java.net package for making HTTP requests. While the java.net package includes support for caching requests it does not include a default caching implementation like some other libraries — apparently Android developers are left to roll their own. I looked into it, and it seemed pretty straightforward to implement the ResponseCache, CacheRequest and CacheResponse classes, but there was a surprise waiting for when I tested my work. It was annoying so I thought I’d share. What follows is a simple example of how to implement ResponseCache, the surprise I found, and how I dealt with it.

Read the rest of this entry »