Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if Image is in Cache - Universal Image Loader

I guess the title says it all. I tried:

imageLoader.getMemoryCache().get(key); 

with the image uri as key, but it always return null

although I enabled caching in the config.

like image 634
fweigl Avatar asked Mar 19 '13 16:03

fweigl


2 Answers

Use MemoryCacheUtils.

MemoryCacheUtils.findCachedBitmapsForImageUri(imageUri, ImageLoader.getInstance().getMemoryCache());

Memory cache can contain several bitmaps (diffenrent sizes) for one image. So memory cache use special keys, not image urls.

like image 86
nostra13 Avatar answered Sep 23 '22 05:09

nostra13


It should be MemoryCacheUtils, so you should use

MemoryCacheUtils.findCachedBitmapsForImageUri(imageUri, ImageLoader.getInstance().getMemoryCache());
like image 32
user1228632 Avatar answered Sep 26 '22 05:09

user1228632