0
votes

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.

1
Picasso has offline cache option. See link - Fatih Santalu
I found this Picasso.with(mContext) .load(url) .networkPolicy(NetworkPolicy.OFFLINE) .into(imageView); but error: cannot find symbol variable NetworkPolicy - Mursal Khan
cannot resolve method networkPolicy() - Mursal Khan
Solved it. My picasso version was old. i updated it. it's solved. Thankyou so much <3 - Mursal Khan

1 Answers

0
votes

Solved it!

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

Thankyou so much guys <3