2

I want to get Image from cache memory, I am using volley library and displaying image successfully. I want to get same downloaded image from cache
Below is my code.

Cache cache = AppController.getInstance().getRequestQueue().getCache();
Entry entry = cache.get(ImageUrl);
if (entry != null) {
    try {
        // Get Data From Catch Successefully
        String data = new String(entry.data, "UTF-8");

        // but now this code return null value i want Bitmap From Catch
        LruBitmapCache bitmapCache = new LruBitmapCache();
        mBitmap = bitmapCache.getBitmap(data);


    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
}


I can get data from cache, but bitmapCache.getBitmap(data); return's null.

alex
  • 8,904
  • 6
  • 49
  • 75
Rajneesh
  • 272
  • 2
  • 5
  • 16

1 Answers1

2

use this line instead to convert entry.data into bitmap:

mBitmap = BitmapFactory.decodeByteArray(entry.data, 0, entry.data.length);
Piyush
  • 18,895
  • 5
  • 32
  • 63
Mariel Dee
  • 21
  • 3