0

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.

Tim
  • 2,089
  • 1
  • 12
  • 21
  • What is your `targetSdkVersion`, and what is the version of Android that you are testing on? – CommonsWare Dec 12 '15 at 15:34
  • minSdkVersion 14, targetSdkVersion 23, running on 23 in virtual device – Tim Dec 12 '15 at 15:43
  • Thank you, I did search a lot but couldn't find that question, or any info that led me towards a change in sdk 23. – Tim Dec 12 '15 at 15:47
  • @CommonsWare, what is protocol for duplicate questions? Should I delete it? – Tim Dec 12 '15 at 15:55
  • You are welcome to leave it here. It may be that your question turns up in search results for some future user, who can then follow the duplicate link to information about the problem. That being said, you are also welcome to delete it, if you wish. – CommonsWare Dec 12 '15 at 15:56

0 Answers0