Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To download and caching bitmap using Picasso library

I am using the following method

Bitmap bitmap = Picasso.with(ListofCardsActivity.this)
                            .load(overLayUrl).get();

for downloading and get the image from the web url.

Does this method download the image from the url every time, even if it is downloaded already?

What I want is that once the image is downloaded, then from the next time onwards, I should get the image from the cache, no need to download.

If we have the method like the above requirement. please let me know

like image 892
AndroidDev Avatar asked Apr 02 '14 07:04

AndroidDev


1 Answers

Does this method download the image from the url every time, even if it is downloaded already?

Not if it is cached.

The Picasso instance you get back with with() is pre-configured to have a memory cache and a disk cache.

Depending on how much you are downloading, you may run out of cache space. And I would hope that Picasso uses stuff like ETag and If-Modified-Since to re-download the image if the image has changed on the server, though I have not examined their code to see if they do, as that behavior is not documented.

like image 120
CommonsWare Avatar answered Oct 19 '22 13:10

CommonsWare