我正在创建一个应用程序来拍摄图片,然后我读取它们。当图片存储在SD卡中时,我可以很好地读取它们,但当它们存储在电话内存中时,我可以找到它们(newFile显示正确的路径),但我在图像视图中看不到它们。在三星手机中,它们存储在/存储/模拟/0/图片/应用程序图像中,在这样的情况下,我无法在ImageView中读取和显示
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "AppImages");
final ImageView newImage = new ImageView(this);
File newFile = new File(mediaStorageDir+File.separator+files.getString(2));
//I have tried this 3 options one at a time
final Bitmap bmp = BitmapFactory.decodeFile(newFile.getAbsolutePath());
final Bitmap bmp = BitmapFactory.decodeStream(new FileInputStream(newFile));
final Bitmap bmp = BitmapFactory.decodeFile(newFile.getPath());
newImage.setImageBitmap(bmp);发布于 2015-06-25 05:20:23
你试过MediaStore了吗?
看看这个:
MediaStore.Images.Media.EXTERNAL_CONTENT_URI //from external storage
MediaStore.Images.Media.INTERNAL_CONTENT_URI //from internal storage看看这个链接
发布于 2017-12-11 13:21:52
问题是我在图片库中显示了完整的图片,并将其调整为缩略图大小,从而解决了问题。
https://stackoverflow.com/questions/31037737
复制相似问题