I'm trying to access the photos on external storage. I added the permission to AndroidManifest.xml
:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
I put it right in line under the working permissions, such as INTERNET
.
Here's the code that calls for a file (this is returning from the ACTION_PICK
intent, which is working fine to view and select a photo):
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 100)
if (resultCode == Activity.RESULT_OK) {
Uri selectedImage = data.getData();
WelcomeActivity.selectedLesson.setScoreFile(selectedImage);
scoreView.setImageURI(selectedImage);
}
}
However, the last line, scoreView.setImageURI(selectedImage)
creates the following error:
Unable to open content: content://media/external/images/media/17
java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media/17 from pid=23262, uid=10055 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
So how can it say requires android.permission.READ_EXTERNAL_STORAGE
if I've already provided it? And I get no pop-up when starting the application asking for permission.