Android image caching

d-man picture d-man · Dec 22, 2009 · Viewed 109.4k times · Source

How can I cache images after they are downloaded from web?

Answer

edrowland picture edrowland · Oct 8, 2010

And now the punchline: use the system cache.

URL url = new URL(strUrl);
URLConnection connection = url.openConnection();
connection.setUseCaches(true);
Object response = connection.getContent();
if (response instanceof Bitmap) {
  Bitmap bitmap = (Bitmap)response;
} 

Provides both memory and flash-rom cache, shared with the browser.

grr. I wish somebody had told ME that before i wrote my own cache manager.