How can I save an image from a url?

后端 未结 5 1133
情深已故
情深已故 2020-12-17 05:53

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 interne

5条回答
  •  太阳男子
    2020-12-17 06:30

    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.

提交回复
热议问题