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.