I suffer from "open failed: EACCES (Permission denied)" on Android when I try to write "/ mnt / sdcard / report /". My first step is to create a βreportβ folder that does not work. Then I try to write which throws an exception above. I set <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> as the application tag (outside) of the application. I am trying to run a JUnit test test on an emulator when I get an error. Any ideas? The code is below.
if (mReportDir == null) { if (mContext.getFilesDir() != null) { mOutputStream = mContext.openFileOutput(fileName, 0); } else { mOutputStream = mTargetContext.openFileOutput(fileName, 0); } } else { File f = new File(mReportDir); if (!f.exists()) { f.mkdirs(); } mOutputStream = new FileOutputStream(new File(mReportDir, fileName)); }
mReportDir equals "/ mnt / sdcard / report", fileName equals "junit-report.xml", f.mkdirs returns false, I believe, and the directory is never created. I wonder why I allow permission. I am trying to reuse a custom JUnit Test runner.
I added hw.sdCard = yes for avd settings. After starting the shell I and mounting the type:
~$ adb shell
Again, I run AVD programmatically from an Ant script. Is there something I can do programmatically to install an SD card?
Cliff source share