Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement my own disk cache with picasso library - Android?

Tags:

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.

like image 405
Dax Avatar asked Sep 22 '13 14:09

Dax


People also ask

What is disk cache in android?

There are two types of caching as follows: Memory cache is the fastest cache to get the data as this is in memory. Disk Cache: It saves the data to the disk. If the application gets killed, the data is retained. Useful even after the application restarts. Slower than memory cache, as this is I/O operation.

What is Fresco cache?

Overview. Fresco is a powerful library for displaying images in Android, supporting applications all the way back to GingerBread (API 9). It downloads and caches remote images in a memory efficient manner, using a special region of non-garbage collected memory on Android called ashmem .


1 Answers

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

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

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-

like image 123
Jake Wharton Avatar answered Sep 21 '22 08:09

Jake Wharton