16

I want to use the DiskLruCache from Jake Wharton in my Android app based on API Level 7+. I would use it in my ListView to Cache downloaded images on SdCard but i didn't understood the usage of this library. Can anybody show me a example of how to get Bitmaps from this Cache or put Bitmaps in the cache? ( key = filePath, value = Bitmap )

I found no method to get the Value of this Snapshot Object.

Thanks for every help.

Daniel Smith
  • 8,561
  • 3
  • 35
  • 58
Happo
  • 1,375
  • 3
  • 16
  • 34

2 Answers2

7

I used getBitmap() in the sample someone posted here.

This is the answer you're looking for under a different title. You will have to create a Utils for some of the code but it's pretty straightforward.

Good Luck!

Using DiskLruCache in android 4.0 does not provide for openCache method

Community
  • 1
  • 1
John Stack
  • 618
  • 1
  • 4
  • 19
  • I'm using: imgCache = new DiskLruImageCache(context, "images", DISK_CACHE_SIZE); imgCache.put(id, scaleImage(bmp)); to store. And Bitmap b = imgCache.getBitmap(id); to retrieve a bitmap from this cache. But it says image not found. Any ideas why? – Rameez Hussain Oct 09 '12 at 09:19
  • I have the same issues. – Navetz Aug 26 '13 at 21:40
4

You can also try this very easy to use DiskLruCache wrapper: https://github.com/fhucho/simple-disk-cache

fhucho
  • 34,062
  • 40
  • 136
  • 186