1. How to get Cache size
Well, you can do that like this :
StatsSnapshot picassoStats = Picasso.with(context).getSnapshot();
The statsSnapshot
object contains the following params :
StatsSnapshot{
maxSize=28760941,
size=26567204,
cacheHits=30,
cacheMisses=58,
downloadCount=0,
totalDownloadSize=0,
averageDownloadSize=0,
totalOriginalBitmapSize=118399432,
totalTransformedBitmapSize=96928004,
averageOriginalBitmapSize=2466654,
averageTransformedBitmapSize=2019333,
originalBitmapCount=48,
transformedBitmapCount=41,
timeStamp=1432576918067}
Read more here
2. How to clear cache
There is no direct method (in Picasso) to clear the entire cache because :
Picasso doesn't have a disk cache, the HTTP client is responsible for it. You can install your own disk cache into the HTTP client and delete the contents of the folder to clear it if you want.
Source : Picasso Issue#1543 and Picasso Issue#1521
but if what you want is to force refresh a single image, you can specify NO_CACHE
for both memoryPolicy
and diskPolicy
to skip the cache and force refresh.
Picasso.with(context)
.load(newUri)
.memoryPolicy(MemoryPolicy.NO_CACHE)
.diskPolicy(MemoryPolicy.NO_CACHE)
.into(imageView);
or
you can just call invalidate on the url
Picasso.with(context).invalidate(uri.toString());