android - FileNotFoundException EACCES (Permission Denied) -
i'm getting exception file open permission denied when i'm trying open fileinputstream.
file myfile = new file(environment.getexternalstoragedirectory() .getabsolutepath() + "/test/test.txt"); try { fileinputstream instream = new fileinputstream(myfile); // crash
here's stacktrace:
system.err﹕ java.io.filenotfoundexception: /storage/emulated/0/test/test.txt: open failed: eacces (permission denied) system.err﹕ @ libcore.io.iobridge.open(iobridge.java:456) system.err﹕ @ java.io.fileinputstream.<init>(fileinputstream.java:76) ... caused by: android.system.errnoexception: open failed: eacces (permission denied) @ libcore.io.posix.open(native method) @ libcore.io.blockguardos.open(blockguardos.java:186) @ libcore.io.iobridge.open(iobridge.java:442)
and yes, have permissions in manifest:
<uses-permission android:name="android.permission.read_external_storage" /> <uses-permission android:name="android.permission.write_external_storage" />
android case sensitive. replace android.permission
android.permission
:
<uses-permission android:name="android.permission.read_external_storage" /> <uses-permission android:name="android.permission.write_external_storage" />
also, should need 1 of permissions. if planning on writing external storage, should not need read_external_storage
.
Comments
Post a Comment