I am facing a shitty problem. I can't seem to get my app write to external storage(or anywhere). The app is running on a Android 4.4.4 KitKat device with the known SD card issue. But other apps of mine(compiling against lower Android versions) can still write to external storage on this device.. I have set the correct permission. Can someone please answer how to fix this crap.
Stacktrace:
java.io.FileNotFoundException: /storage/emulated/0/tb_Totaal.txt: open failed: EACCES (Permission denied)
Code:
File directoryFile = new File(Environment.getExternalStorageDirectory(), "");
directoryFile.mkdirs();
File f = new File(Environment.getExternalStorageDirectory(), "/text.txt");
FileWriter writer = new FileWriter(f.getPath());
Permissions:
<uses-permission android:name="android.permission.write_external_storage"/>
<uses-permission android:name="android.permission.read_external_storage"/>
Permissions names are case sensitive. Try using:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
READ_EXTERNAL_STORAGE
permission as it is automatically obtained when you require the WRITE_EXTERNAL_STORAGE
permission.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.