我在SQLite数据库中存储图像路径(来自图库的图像),现在加载到图像视图中...并使用此代码:
File imgFile = new File(cursor.getString(cursor.getColumnIndex("pic")));
if (imgFile.exists()) {
IMG_USER.setImageBitmap(BitmapFactory.decodeFile(cursor.getString(cursor.getColumnIndex("pic"))));
} else { Toast.makeText(this, "عکس پیدا نشد", Toast.LENGTH_LONG); }
和错误:
E / BitmapFactory:无法解码流:java.io.FileNotFoundException:/storage/emulated/0/DCIM/Camera/IMG_20161230_224205.jpg(Permission denied)
答案 0 :(得分:1)
您需要访问权限,将此代码添加到android清单
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
或试试这个
Exception 'open failed: EACCES (Permission denied)' on Android