Android - How to get image file from Fresco disk cache?

Eldar Miensutov picture Eldar Miensutov · Apr 21, 2015 · Viewed 13.6k times · Source

I am using the Fresco library.

I can't find any related info in the Fresco documentation, how can I get an image file from Fresco's disk cache?

Answer

danhantao picture danhantao · Jul 24, 2015

if the image have download in cache,you can do it like:

ImageRequest imageRequest=ImageRequest.fromUri(url);
CacheKey cacheKey=DefaultCacheKeyFactory.getInstance()
     .getEncodedCacheKey(imageRequest);
BinaryResource resource = ImagePipelineFactory.getInstance()
     .getMainDiskStorageCache().getResource(cacheKey);
File file=((FileBinaryResource)resource).getFile();