1

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.

Eliran Tutia
  • 675
  • 1
  • 6
  • 21
  • can you post a sample of what you have tried with invalidate which didn't work to better understand the problem before directly jumping to other solution? – KunalK Apr 18 '16 at 12:16

2 Answers2

2

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

Community
  • 1
  • 1
Kirill Shalnov
  • 2,165
  • 1
  • 16
  • 20
0

Update your picasso library:

compile 'com.squareup.picasso:picasso:2.5.2'.

As Picasso.invalidate() only available for gradle version 2.5.0 and above.

And to clear cache use below function:

Picasso.with(context).invalidate(file);
Dhaval Patel
  • 9,209
  • 4
  • 42
  • 44