且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从Android Picasso缓存中删除所有文件

更新时间:2023-11-20 10:08:04

几天前,我本人正在寻找如何清除整个缓存的方法,然后偶然在***上偶然发现了它,现在似乎找不到线程了,但这是我的代码

I myself was searching on how to clear the whole cache few days back and stumbled upon it on *** itself, cannot seem to find the thread now but here's my code.

将此类添加到 com.squareup.picasso 包中:

 package com.squareup.picasso;

    public class PicassoTools {

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

只需在注销方法上调用它即可:

And simply call this on logout method :

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