Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear Cache memory of Picasso

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);
like image 959
Parthiban M Avatar asked Dec 16 '14 10:12

Parthiban M


2 Answers

Use this instead :

 Picasso.with(getContext()).load(data.get(pos).getFeed_thumb_image()).memoryPolicy(MemoryPolicy.NO_CACHE).into(image);
like image 162
Mohamed Avatar answered Nov 10 '22 08:11

Mohamed


Remove cache of Picasso like this.

public class Clear {

    public static void clearCache (Picasso p) {
        p.cache.clear();
    }
}

This util class can clear the cache for you. You just have to call it:

Clear.clearCache(Picasso.with(context));

EDIT:
The class Clear must be in the package :

package com.squareup.picasso;

Because cache is not accessible from outside that package. Like in this answer: https://stackoverflow.com/a/23544650/4585226

like image 12
Murtaza Khursheed Hussain Avatar answered Nov 10 '22 08:11

Murtaza Khursheed Hussain