如何实现与毕加索库我自己的磁盘缓存 - 安卓? [英] How to implement my own disk cache with picasso library - Android?

查看:108
本文介绍了如何实现与毕加索库我自己的磁盘缓存 - 安卓?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是毕加索库加载图像,我的应用程序。但我不如何实现我自己的盘(SD卡)的缓存与毕加索库。请人帮我解决这个问题。

I'm using picasso library to load images for my app. But i don't how to implement my own disk (sdcard) caching with picasso library. Please anybody help me to solve this issue.

推荐答案

毕加索使用HTTP客户端磁盘缓存,如果其中一个已配置它将使用,而不是安装它自己。

Picasso uses the HTTP client for disk caching and if one is already configured it will use that instead of installing its own.

有关内置的​​URLConnection的文档安装高速缓存的位置:的https://developer.android.com/reference/android/net/http/Htt$p$psponseCache.html

For the built-in UrlConnection the docs for installing a cache are here: https://developer.android.com/reference/android/net/http/HttpResponseCache.html

如果您使用的是OkHttp那么你只需要调用setCache: <一href="http://square.github.io/okhttp/2.x/okhttp/com/squareup/okhttp/OkHttpClient.html#setCache-com.squareup.okhttp.Cache-" rel="nofollow">http://square.github.io/okhttp/2.x/okhttp/com/squareup/okhttp/OkHttpClient.html#setCache-com.squareup.okhttp.Cache-

If you are using OkHttp then you just call setCache: http://square.github.io/okhttp/2.x/okhttp/com/squareup/okhttp/OkHttpClient.html#setCache-com.squareup.okhttp.Cache-

这篇关于如何实现与毕加索库我自己的磁盘缓存 - 安卓?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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