【发布时间】:2012-08-06 07:07:05
【问题描述】:
可能重复:
Android: How to store images from url & save it in SD card
我从 web 解析一个 xml 文件
它有一个像这样的图片网址:http://xxxxxx.jpg
然后我用一个
私有字符串 url_picture = "http://xxxxx.jpg";
我想将图片存储到设备中
我该怎么办?
【问题讨论】:
标签: android
可能重复:
Android: How to store images from url & save it in SD card
我从 web 解析一个 xml 文件
它有一个像这样的图片网址:http://xxxxxx.jpg
然后我用一个
私有字符串 url_picture = "http://xxxxx.jpg";
我想将图片存储到设备中
我该怎么办?
【问题讨论】:
标签: android
我编写了这段代码来接收来自 url 的图像。如果您查看此链接,它会告诉您如何将其保存在 sd 卡上 Store Bitmap image to SD Card in Android
private Bitmap getBitmap(String str, Options options) {
// TODO Auto-generated method stub
Bitmap bm = null;
InputStream inStream = null;
try {
inStream = HttpConnection(str);
bm = BitmapFactory.decodeStream(inStream, null, options);
inStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bm;
}
【讨论】: