Failed to open FIleNotFound: EACCES (permission denied)

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 # mount rootfs / rootfs ro 0 0 tmpfs /dev tmpfs rw,nosuid,mode=755 0 0 devpts /dev/pts devpts rw,mode=600 0 0 proc /proc proc rw 0 0 sysfs /sys sysfs rw 0 0 none /acct cgroup rw,cpuacct 0 0 tmpfs /mnt/asec tmpfs rw,mode=755,gid=1000 0 0 tmpfs /mnt/obb tmpfs rw,mode=755,gid=1000 0 0 none /dev/cpuctl cgroup rw,cpu 0 0 /dev/block/mtdblock0 /system yaffs2 ro 0 0 /dev/block/mtdblock1 /data yaffs2 rw,nosuid,nodev 0 0 /dev/block/mtdblock2 /cache yaffs2 rw,nosuid,nodev 0 0 

Again, I run AVD programmatically from an Ant script. Is there something I can do programmatically to install an SD card?

+4
source share
1 answer

Found a problem! When I created the AVD, I never specified the size of the SD card. I edited and set the size to 512MiB, and now it is writable! Thanks to all who responded!:)

+10
source

Source: https://habr.com/ru/post/1434076/


All Articles