我无法将图像从SD卡加载到Android Studio中的ImageView

时间:2019-02-16 06:36:00

标签: java android

imageView=(ImageView)findViewById(R.id.img);
String pathName = Environment.getExternalStorageDirectory().toString() + "/person.png";
Bitmap bmp = BitmapFactory.decodeFile(pathName);
imageView.setImageBitmap(bmp);

1 个答案:

答案 0 :(得分:0)

请查看您的应用是否有权读取外部存储设备,即Manifest.permission.READ_EXTERNAL_STORAGE

String photoPath = Environment.getExternalStorageDirectory() + "/abc.jpg";
Bitmap bitmap1 = BitmapFactory.decodeFile(photoPath);
imageView.setImageBitmap(bitmap1 );