Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalidate cache in Picasso

I load an image from disk using Picasso, e.g., Picasso.with(ctx).load(new File("/path/to/image")).into(imageView), but whenever I save a new image in that file, and refresh my ImageView, Picasso still has the bitmap cached.

Is it possible to invalidate the cache in Picasso?

like image 928
Maarten Avatar asked Feb 25 '14 13:02

Maarten


People also ask

How do I refresh my Picasso library?

The reason is that Picasso stores that incorrect image in cache. The only way to reload image is to disable cache completely for that request (not recommended) or clear cache before reloading image. To do it you have to create a new file in com. squareup.

How do you use Picasso cache?

By default, they will store into a local disk first for the extended keeping cache. Then the memory, for the instance usage of the cache. You can use the built-in indicator in Picasso to see where images form by enabling this.


1 Answers

In the recent versions of Picasso, there is a new method for invalidate, without any workarounds, so I think that custom PicassoTools class mentioned earlier, is now obsolete in this case

Picasso.with(getActivity()).invalidate(file); 
like image 51
mes Avatar answered Sep 23 '22 02:09

mes