I am using Picasso to load images from my server. It works fine, but I am loading an image, and changed it later. But Picasso has the image cached somewhere in disk (I checked the SD card, and could not find any directory that Picasso is storing in).
I tried to remove the cache as suggested by the accepted answer to this question : Invalidate cache in Picasso
I also tried skipping cache when loading images using : Picasso.with(ctx).load(new File("/path/to/image")).skipMemoryCache().into(imageView)
But none of these methods are working.
Thanks for any suggestion or hint that could help me pass this problem.
Picasso
disk images are cached in app internal cache directory . Look at the methodcreateDefaultCacheDir
here https://github.com/square/picasso/blob/master/picasso/src/main/java/com/squareup/picasso/Utils.javaYou can clear all the images in
getCacheDir/picasso-cache
like thisTo delete all files in directory
You can read this entry https://stackoverflow.com/a/18964588/2358095 to understand how picasso disk cache works.
So first of all you have to add
static void delete(Object cache)
method in ResponseCacheIcs class. This class is defined in UrlConnectionDownloader.java. It seems like that:After that you have to add
method in Downloader.java. Then you have to add unimplemented method in UrlConnectionDownloader.java and OkHttpDownloader.java. You should define
public void clearDiskCache()
method in UrlConnectionDownloader.java like this:Then you have to add:
method in Dispacher.java. And then add:
method in Picasso.java.
Bingo!!! Now you can call
clearDiskCache()
method in your code. Here is an example: