1
我已经搜索并尝试了一切,我在Google和StackOverflow上发现了关于此主题的所有内容,但是我没有找到使其工作。 我有这个代码,但它引发了我一个致命的例外。 我认为,因为我是Android新手,所以我做错了一些事情。请帮助我^^Android - 在外部存储器上使用其URL保存图片
public void svgPhoto() throws IOException {
String dir = Environment.getExternalStorageDirectory().toString();
OutputStream fos = null;
File file = new File(dir,"downloadImage.JPEG");
Bitmap bm =BitmapFactory.decodeFile("http://perlbal.hi-pi.com/blog-images/3278/gd/1242316719/Chat-chat.jpg");
fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
bm.compress(Bitmap.CompressFormat.JPEG, 50, bos);
bos.flush();
bos.close();
确保您有'WRITE_EXTERNAL_STORAGE'许可,您的AndroidManifest.xml – 2013-02-28 14:26:00