0

Hi I'm getting an exception java.io.FileNotFoundException:

open failed: EACCES (Permission denied) on android 6.

I have granted the READ_EXTERNAL_STORAGE permission at run time but still getting this error. Please help.

 private void checkForPermissions() {

    // Here, thisActivity is the current activity
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.READ_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED) {

        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.READ_EXTERNAL_STORAGE)) {

            // Show an expanation to the user *asynchronously*  don't block
            // this thread waiting for the user's response! After the user
            // sees the explanation, try again to request the permission.

            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                    PERMISSIONS_REQUEST_ACCESS_PHOTO);
        } else {

            // No explanation needed, we can request the permission.

            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                    PERMISSIONS_REQUEST_ACCESS_PHOTO);
        }
    } else {
        openGalley();
    }
}

private void openGalley() {
    Intent galleryIntent = new Intent(
            Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivityForResult(galleryIntent, rerquestCode);
}
2
  • Seems like you need to show some code. What are you trying to open? Feb 2, 2016 at 14:04
  • Have you checked the actual permission needed? It should be shown in the system log before you get the exception.
    – 3c71
    Apr 17, 2016 at 8:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.