I'm trying to clear the cache memory of Picasso via Android coding.
Can anyone please help me in this issue..?
I have tried using the following code, but this was not useful in my case:
Picasso.with(getActivity()).load(data.get(pos).getFeed_thumb_image()).skipMemoryCache().into(image);
If you keep reference of your custom
Downloader
implementation you can clear cache.It is important to have access to your http client and its
Cache
. In my implementation there is access to the cache, hence clearing cache withclearCache()
method.Remove cache of Picasso like this.
This util class can clear the cache for you. You just have to call it:
EDIT:
The class Clear must be in the package :
Because cache is not accessible from outside that package. Like in this answer: https://stackoverflow.com/a/23544650/4585226
This also works
Use this instead :
if you are trying to load an image through Json(from db) try clearing the networkCache for a better result.
i had the same problem. It worked for me. I used Picasso in RecycleView inside a dialog. When i closed dialog, picasso doesnt clear cache. But while you are using the dialog it clears image cache. However there is some cache that is not cleared. Maybe the cache that was not cleared is the last you seen in dialog before dialog.dismiss().
use this memoryPolicy(MemoryPolicy.NO_CACHE,MemoryPolicy.NO_STORE)