如何从Android Picasso缓存中删除所有文件 [英] How to delete all files from Android Picasso cache

查看:103
本文介绍了如何从Android Picasso缓存中删除所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个项目中,我使用毕加索( http://square.github.io/picasso/)以将所有图像加载到Recycler View中,我想在注销应用程序时从Picasso缓存中删除所有文件.您能帮我做到这一点吗,我不想分别使每个文件无效,它也不会将所有文件保存在哪里?

I am working on a project where iam using picasso (http://square.github.io/picasso/) to load all the images in a Recycler View, i wanted to remove all the files from the Picasso cache at the time of logging out of the application. Can you please help me how to do that, i dont want to invalidate every single file separately, also where does it save all the files?

推荐答案

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

I myself was searching on how to clear the whole cache few days back and stumbled upon it on Stackoverflow 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));

这篇关于如何从Android Picasso缓存中删除所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆