For the latest version 2.71828, this is your answer.
Q1 : Does it have no local disk cache?
A1 : Picasso has default caching and request flow like this
App -> Memory -> Disk -> Server
Wherever they first encounter their image, they will use that image and then stop the flow of requests. What about the response flow? Donโt worry, here it is.
Server -> Disk -> Memory -> App
By default, they are first saved to the local drive for extended cache storage. Then memory, to use the cache instance.
You can use the built-in indicator in Picasso to see where the images are formed by turning this on.
Picasso.get().setIndicatorEnabled(true);
It will show a flag in the upper left corner of your photos.
- A red flag means that images are coming from the server. (No caching on first boot)
- A blue flag means that photos came from a local drive. (Caching)
- A green flag means that images come from memory. (Instance Caching)
Q2 : How to enable caching on disk, since I will use the same image several times?
A2 : You do not need to turn it on. This is the default.
What you need to do is turn it off when you want your images to always be fresh. There are 2 ways to disable caching.
- Set
.memoryPolicy() to NO_CACHE and / or NO_STORE, and the stream will look like this.
NO_CACHE will skip the search for images from memory.
App -> Disk -> Server
NO_STORE will skip storing images in memory the first time images are loaded.
Server -> Disk -> App
- Set
.networkPolicy() to NO_CACHE and / or NO_STORE, and the stream will look like this.
NO_CACHE will skip the search for images from disk.
App -> Memory -> Server
NO_STORE will skip saving images to disk when loading images for the first time.
Server -> Memory -> App
You cannot disable a single one to not cache images completely. Here is an example.
Picasso.get().load(imageUrl) .memoryPolicy(MemoryPolicy.NO_CACHE,MemoryPolicy.NO_STORE) .networkPolicy(NetworkPolicy.NO_CACHE, NetworkPolicy.NO_STORE) .fit().into(banner);
A stream completely without caching and storage will not look like this.
App -> Server
Thus, you may need this to minimize the memory usage of your application.
Q3 : Do I need to add some disk permissions to the Android manifest file?
A3 : No, but do not forget to add the INTERNET permission for your HTTP request.