I'm getting an exception that file open permission is denied when I'm trying to open a FileInputStream.
File myFile = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/test/test.txt");
try {
FileInputStream inStream = new FileInputStream(myFile); // crash
Here's the stacktrace:
System.err﹕ java.io.FileNotFoundException: /storage/emulated/0/test/test.txt: open failed: EACCES (Permission denied)
System.err﹕ at libcore.io.IoBridge.open(IoBridge.java:456)
System.err﹕ at java.io.FileInputStream.<init>(FileInputStream.java:76)
...
Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
And yes, I do have the permissions in my manifest:
<uses-permission android:name="ANDROID.PERMISSION.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="ANDROID.PERMISSION.WRITE_EXTERNAL_STORAGE" />
Android is case sensitive. Replace
ANDROID.PERMISSION
withandroid.permission
:Also, you should only need one of those permissions. If you are planning on writing to external storage, you should not also need
READ_EXTERNAL_STORAGE
.