Howto avoid the "EACCES permission denied" ON SDCARD with KITKAT 4.4.2 Version. New policy from google

mcfly soft picture mcfly soft · Mar 14, 2014 · Viewed 69.5k times · Source

With the android kitkat 4.4.2 version is a new google policy implemented for writeaccess, which I do not understand so far.

I read a lot about this issue with other apps. They get a "EACCES permission denied". My app needs to write/unzip a zipfile, also write to a sqlite-database.

How can this EACCES permission denied issue be solved with Android version 4.4.2 KITKAT ?

Answer

nikis picture nikis · Mar 14, 2014

From the docs:

Starting in Android 4.4, multiple external storage devices are surfaced to developers through Context.getExternalFilesDirs(), Context.getExternalCacheDirs(), and Context.getObbDirs().

External storage devices surfaced through these APIs must be a semi-permanent part of the device (such as an SD card slot in a battery compartment). Developers expect data stored in these locations to be available over long periods of time. For this reason, transient storage devices (such as USB mass storage drives) should not be surfaced through these APIs.

The WRITE_EXTERNAL_STORAGE permission must only grant write access to the primary external storage on a device. Apps must not be allowed to write to secondary external storage devices, except in their package-specific directories as allowed by synthesized permissions. Restricting writes in this way ensures the system can clean up files when applications are uninstalled.