Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear cache and Reload Image in Picasso?

I am using Picasso to load image in my application but i facing a issue that my image URL is same but image is changing from backend calling the same URL but Picasso loading the same image saved in its cache. Now i want to clear the cache for that Image and reload the image again.

What i have tried i searched on SO find that we can use picasso.invalidate(fileName); or memoryPolicy(MemoryPolicy.NO_CACHE) but i am getting the error message in code

Can't reslove method invalidate

Can't reslove method memoryPolicy

dependency for picasso in gradle :

compile 'com.squareup.picasso:picasso:2.4.0'
like image 916
Kapil Rajput Avatar asked Nov 07 '16 06:11

Kapil Rajput


1 Answers

Try to use this.

 Picasso.with(context).invalidate(url); 
 Picasso.with(context).load(url).networkPolicy(NetworkPolicy.NO_CACHE).memoryPolicy(MemoryPolicy.NO_CACHE); 

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

like image 145
Cristian Cardoso Avatar answered Sep 19 '22 01:09

Cristian Cardoso