简体   繁体   中英

Writing files to external SDCard -android

我一直在尝试将应用程序中的文件写入外部sdcard,但未写入文件,我的测试手机是Galaxy Duos和LG,当我在LG手机上尝试时,它可以正常工作,但是LG手机具有android版本是4.1.2。而星系是4.4.2,我想这与kitkat 4.4中SDCard的变化有关,想知道是否有人可以解决它?

In 4.4 the application can not write data to any place on the external SD card. The application can write the data only to certain folders on the external card (under /extSdCard/Android/data/ path). This is a new restriction imposed by Google that is supposed to allow users to delete all data associated to the application after the application is uninstalled.

Here's the detailed explanation .

With Android 4.4 (KitKat), Google blocked apps from writing to the SD card except for a very specific sandboxed location. Apps have direct write access ONLY to their package-specific directories as obtained through Context.getExternalFilesDirs(), Context.getExternalCacheDirs(), etc. "Direct" access is defined as using traditional file access APIs, like POSIX open(). Direct access to the remainder of these secondary external storage devices remains read-only for apps.

However, apps can create/write files outside of their package-specific directories on secondary external storage devices by using the new CREATE_DOCUMENT intent, which involves the user in the file creation process.

Notably, Google's Nexus devices do not include micro SD card support; however, many other Android-powered devices do feature micro SD card functionality. The previous version of Android left devices vulnerable from a security standpoint, but Google has now addressed these safety concerns by limiting what third-party apps can do with a Micro SD card.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM