Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I save an image from a url?

I'm setting an ImageView using setImageBitmap with an external image url. I would like to save the image so it can be used later on even if there is no internet connection. Where and how can I save it?

like image 885
Amit Avatar asked Dec 07 '22 15:12

Amit


1 Answers

URL imageurl = new URL("http://mysite.com/me.jpg"); 
Bitmap bitmap = BitmapFactory.decodeStream(imageurl.openConnection().getInputStream()); 

This code will help you in generating the bitmap from the image url.

This question answers the second part.

like image 154
coderplus Avatar answered Dec 09 '22 04:12

coderplus