androidcachingpicassoclear-cache

Picasso cache clear


I already saw every solution that proposed here and nothing really works for me.

How can i clear the cache of Picasso in my app?

I've tried to use invalidate - isn't work. I saw something about Picasso.cache.clear, but impossible to access directly to cache.

(please don't suggest me to use NO_CACHE)

Thanks.


Solution

  • get from this answer

    Add this class to the com.squareup.picasso package.

    package com.squareup.picasso;
    
    public class PicassoTools {
    
        public static void clearCache (Picasso p) {
            p.cache.clear();
        }
    }
    

    Because cache has package visibility, this util class can clear the cache for you. You just have to call it:

    PicassoTools.clearCache(Picasso.with(context));
    

    Just add this file to a path .../java/com/squareup/picasso

    P.S. I strongly recommend use glide instead of picasso, it has more powerful features to cache control and awesome download-callbacks to catch download errors, for example