如何从SD卡图像中的android? [英] How to get image from sdcard in android?
本文介绍了如何从SD卡图像中的android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建简单的应用程序中,我想从SD卡,但不能老是成功获取图像。 我的code低于
i want create simple app in which i want get the image from sdcard but can`t success. my code is below
File myFile = new File("/sdcard/photo.jpg");
ImageView jpgView = (ImageView)findViewById(R.id.imageView);
BitmapDrawable d = new BitmapDrawable(getResources(), myFile.getAbsolutePath());
jpgView.setImageDrawable(d);
但不能老是获取图像。
but can`t get the image.
推荐答案
使用低于code,而不是你code。
Use below code instead of your code.
File f = new File("/mnt/sdcard/photo.jpg");
ImageView mImgView1 = (ImageView)findViewById(R.id.imageView);
Bitmap bmp = BitmapFactory.decodeFile(f.getAbsolutePath());
mImgView1.setImageBitmap(bmp);
这篇关于如何从SD卡图像中的android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文