简体   繁体   中英

Android: ImageView and SD-card

I am trying to read an image from /mnt/sdcard/img.jpg into ImageView.

Bitmap bm = BitmapFactory.decodeFile("/mnt/sdcard/img.jpg");     
imageView1.setImageBitmap(bm);

I have write external storage permission.

But ImageView is empty, LogCat don't get any errors,

How can I fix it?

Try

File file = new File("/mnt/sdcard/img.jpg");
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
imageview1.setImageBitmap(bitmap);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM