Below code started failing with Error 09-07 15:42:52.174: W/System.err(11739): java.io.FileNotFoundException: /storage/sdcard/NumberType.txt: open failed: EACCES (Permission denied)
Strangely I am able to read the files as expected. It only fails as soon as I try to write something. It's failing in line fileOut = new FileOutputStream(file,true); with below trace.
09-07 15:42:52.174: W/System.err(11739): java.io.FileNotFoundException: /storage/sdcard/DixitMobileUsage/NumberType.txt: open failed: EACCES (Permission denied)
09-07 15:42:52.177: W/System.err(11739): at libcore.io.IoBridge.open(IoBridge.java:456)
09-07 15:42:52.177: W/System.err(11739): at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
09-07 15:42:52.177: W/System.err(11739): at ind.cosmos.utilities.FileManager.appendContentToBottomInFile(FileManager.java:263)
09-07 15:42:52.177: W/System.err(11739): at ind.cosmos.main.UNKNOWN_POPUP$1$1.onClick(UNKNOWN_POPUP.java:117)
Code :
FileOutputStream fileOut = null;
BufferedWriter bw = null;
try
{
fileOut = new FileOutputStream(file,true);
bw = new BufferedWriter(new OutputStreamWriter(fileOut, "8859_1"));
if(null != comment)
bw.write(key+"="+value+" \t\t# "+comment);
.
.
I have also mentioned the permissions in the manifest.xml
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I have also searched a lot over net. No solution works for me. It's not even API 23 where I have to write the permission code. :(
Please help.