Writing to SD Card always failing

点点圈 提交于 2019-12-04 18:51:21
Mattia Maestrini

On Android Kitkat (4.4), Google has changed how the developers can access to the removable storage (SD card). Quoting from source.android.com:

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.

For this reason, even with the WRITE_EXTERNAL_STORAGE permission, you can't write on the SD card on KitKat and higher versions.

On Android Lollipop (5.0), Google adds a new set of API that allows the developers to manage the file on the SD Card through the Storage Access Framework.

This StackOverflow answer explains in detail how to use the new APIs and the existing limitations:

How to use the new SD card access API presented for Android 5.0 (Lollipop)?

Is the "uses-permission" tag outside of the "application" tag in the manifest.xml?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!