Search code examples
androidbitmappicassooffline-caching

get bitmap after picasso sets image to an ImageView


I'm trying to save downloaded images in shared preferences in base64 format so that the app can work offline. I've used picasso

Picasso.with(mContext).load(urls.get(position)).into(imageView);

I request the server with a specific category of images and the server responds with a json containing the urls of those images. I found picasso to do this job for me as i need to write my async task for this.The images are loaded into ImageViews of a gridview image adapter.

What I want to do is that as soon as the image is loaded through the url using this function I want that bitmap image so that I can save it in shared preferences or serialize it something so that it can be used offline. or suggest me a better solution.


Solution

  • Solved it!

    Picasso.with(mContext)
                    .load(url)
                    .networkPolicy(NetworkPolicy.OFFLINE)
                    .into(imageView);
    

    Thankyou so much guys <3