Android Filesystem Permissions and POI

Viewed 34

I am trying to read an Excel file in the documents folder (/storage/emulated/0/Documents/). I have gotten the Apache POI library included in my project, and it builds and runs. Upon opening the relevant activity, I run ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1001);. the public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) function is called properly, and it contains super.onRequestPermissionsResult(requestCode, permissions, grantResults); After calling that first function, I try to run the following line of code: InputStream inp = new FileInputStream(Environment.getExternalStorageDirectory() + "/" + Environment.DIRECTORY_DOCUMENTS + "/" + "todo.xlsx"); For some reason, this error: open failed: EACCES (Permission denied) is displayed before it tells me that the permission is granted, which is a Log.d statement after super.onRequestPermissionsResult, but before my attempt to access the file with POI. I have the appropriate <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> line in AndroidManifest.xml.

0 Answers
Related