Android: Displaying .jpg image from sdcard using ImageView

前端 未结 1 1638
慢半拍i
慢半拍i 2021-01-13 18:20

I am trying to display a .jpg from my sd card into an imageview in my layout. I dont get any errors, but nothing gets displayed. I would appreciate any help. Thanks

相关标签:
1条回答
  • 2021-01-13 19:03

    do NOT access the SD card directly, try accessing it trough Environment. Like this:

    String imageDir = Environment.getExternalStorageDirectory()+"/apple.jpg";
    

    and then you can call BitmapFactory:

    Bitmap myBitmap = BitmapFactory.decodeFile(imageDir);
    
    0 讨论(0)
提交回复
热议问题