I'm trying to read a photo off the Android device gallery to display in my app.
My app allows a user to select an image from the gallery and this code within an onActivityResult() method saves the filename for later use:
if (resultCode == Activity.RESULT_OK) {
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getActivity().getContentResolver().query(data.getData(), filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filename = cursor.getString(columnIndex);
cursor.close();
}
I then later try to display the photo in another activity like so:
ImageView photoImageView = (ImageView) itemView.findViewById(R.id.photoImageView);
Uri uri = Uri.fromFile(new File(photoFilename));
Log.i("AddInformationDialog", "URI found: " + uri);
photoImageView.setImageURI(uri)
But I'm getting this Permission Denied error:
WARN/ImageView(14618): Unable to open content: file:///mnt/sdcard/dcim/Camera/2012-05-31_09-37-03_660.jpg
java.io.FileNotFoundException: /mnt/sdcard/dcim/Camera/2012-05-31_09-37-03_660.jpg (Permission denied)
at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
I looked at the Manifest permissions and didn't see one that explicitly allowed an app to read from the filesystem. What am I missing?
Thanx in advance.