我已经看到了这里提出的每一个解决方案,但没有一个真正对我有用。
我如何在我的应用程序中清除毕加索的缓存?
我试过用失效-不管用。我看到了一些关于Picasso.cache.clear的东西,但是不可能直接访问缓存。
(请不要建议我使用NO_CACHE)
谢谢。
发布于 2016-04-18 12:20:45
将该类添加到com.squareup.picasso包中。
package com.squareup.picasso;
public class PicassoTools {
public static void clearCache (Picasso p) {
p.cache.clear();
}
}因为缓存具有包的可见性,所以这个util类可以为您清除缓存。你只需要叫它:
PicassoTools.clearCache(Picasso.with(context));只需将此文件添加到路径./java/com/squareup/picasso
我强烈建议使用https://github.com/bumptech/glide代替毕加索,它有更强大的特性来缓存控制和可怕的下载回调,例如捕捉下载错误。
发布于 2016-04-18 12:27:11
更新您的毕加索库:
compile 'com.squareup.picasso:picasso:2.5.2'。
因为Picasso.invalidate()只适用于gradle版本的2.5.0和更高版本。
要清除缓存,请使用以下功能:
Picasso.with(context).invalidate(file);https://stackoverflow.com/questions/36693568
复制相似问题