Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 217
dreambit.io Avatar asked Apr 21 '15 12:04

dreambit.io


People also ask

Does cache store images?

1. Bitmap cache. The bitmap cache stores decoded images as Android Bitmap objects. These are ready for display or postprocessing.

What is Fresco cache?

Fresco is a graphics library for displaying and managing images in Android applications. It caches the image in a memory-efficient manner. One of the most important features is that it displays a placeholder image until the image loads from the URL. This saves on data and makes efficient use of the CPU.

What is disk cache in android?

This cache take up your application memory so avoid it for storing huge data. Memory cache gets destroyed once app goes background and gets killed by system to save up resources.

What is cache use?

A cache's primary purpose is to increase data retrieval performance by reducing the need to access the underlying slower storage layer. Trading off capacity for speed, a cache typically stores a subset of data transiently, in contrast to databases whose data is usually complete and durable.


1 Answers

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();
like image 187
danhantao Avatar answered Nov 15 '22 16:11

danhantao