Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if image exist in Cache Picasso

I want to check if image url is contained inside cache. I am using Picasso image loader .

this is my code

new Picasso.Builder(this).downloader(new OkHttpDownloader(client)).build();

now Picasso.getCache() does not have get(key) .

though Cache class internally uses LRUDiskCache but its private

Any ideas??

like image 623
Ahmad Avatar asked Dec 22 '15 14:12

Ahmad


1 Answers

Jake already answered this on Twitter (https://twitter.com/JakeWharton/status/679403330809028608), but I'm reposting the answer here for visibility.

You could make a request with a network policy of OFFLINE and if it fails then the image is not in the disk cache.

like image 53
Eric Cochran Avatar answered Sep 17 '22 14:09

Eric Cochran