4

I am trying to write to the SD card from my Android application, it gives error:

java.io.IOException: open failed: EACCES (Permission denied) from latest version           

- android version :-      4.4.2
- Kernel version :-       3.4.5-699287 dpi@SWDD5015 # 1
                          Thu Feb 13 20:28:09 KST 2014
- Build number :-         KOT49H.I9500XXUFNB3

Note : my application has permission

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

I believe WRITE_MEDIA_STORAGE permission should be used to write to SD card.

So when we try

<uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />

It gives error

Permission is only granted to system apps

In camera app settings if we mention storage SD card then it can create pictures in SD card because it is system app. If anybody has any other solution to write on SD card from third party app, please share.

This question is definitely not a duplicate, because prior to this build on SAMSUNG same device I was able to read/write to external SD card.

The answer seems to be, use a new API from API level 19, which are:

  • Context.getExternalFilesDirs()
  • Context.getExternalCacheDirs()
  • Context.getObbDirs()

Solution to this problem is on above link. They have added sandboxing and API.

For example, the app with package name com.example.foo can now freely access Android/data/com.example.foo/ on external storage devices with no permissions. These synthesized permissions are accomplished by wrapping raw storage devices in a FUSE daemon.

I have tested it with API level 19 on my device, It is working fine and I am able to create files on external SD card using new API. I wanted to give an answer with good example but I can't as the question is closed as duplicate.

Community
  • 1
  • 1
Sachin
  • 501
  • 10
  • 18
  • 1
    This should **NOT** be reopened, as the answer to the duplicate explains the problem here - in effect, that it is by (unfortunate) design. – Chris Stratton Mar 05 '14 at 16:31
  • 2
    Your solution should be posted at the duplicate question, not here. – Chris Stratton Mar 05 '14 at 16:36
  • 1
    I have posted answer in [EACCESS Permission denied in Android](http://stackoverflow.com/questions/12853752/eaccess-permission-denied-in-android/22201215#22201215) – Sachin Mar 06 '14 at 12:30
  • I have posted answer in EACCESS Permission denied in Android [enter link description here](http://stackoverflow.com/questions/12853752/eaccess-permission-denied-in-android/22201215#22201215) – Sachin May 12 '16 at 12:26

0 Answers0