Android image caching


Question

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

1
139
9/20/2011 5:09:18 PM

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.

173
3/31/2011 5:03:19 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon