24

For some strange reason, am constantly facing an issue with different types of Android devices, for saving the captured images on the device storage.

Here, is the detailed error log, of what, actually am getting.

java.io.IOException: open failed: EACCES (Permission denied)
at java.io.File.createNewFile(File.java:940)
at com.parkhya.pick_for_shareAflash.HomeActivity.resizeImage(HomeActivity.java:456)
at com.parkhya.pick_for_shareAflash.HomeActivity.onActivityResult(HomeActivity.java:393)
Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
at java.io.File.createNewFile(File.java:933)

Although, all the other Android apps, like, Instagram and others, are able to save the camera clicked images on the devices. Anybody, can you please suggest, what should I do, in order for my app, to save the camera pictures in sdcard.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
srsmohit
  • 241
  • 1
  • 2
  • 3

2 Answers2

22

This may help you. I face the same issue when writing the file on sdcard. I have set all required permission to write the file but I used the file object like below:

Wrong:

File myFile = new File(Environment.getExternalStorageDirectory().getAbsoluteFile()+fileName);

Correct:

File myFile = new File(Environment.getExternalStorageDirectory().getAbsoluteFile(), fileName);

That means the path was wrong.

tjpaul
  • 343
  • 3
  • 16
Smeet
  • 4,036
  • 1
  • 36
  • 47
0

Solution what i find is

edit the Emulator 1. go to android virtual device manager and then edit the emulator 2. set say 100 MB for Sd card for the respected emulator and say Ok 3. save and close emulator and start 4. path saved is click DDMS mnt/sdcard/yourfilename it worked for me the app is not giving Error and is working

madmaskd
  • 11
  • 3