Android4.4 access external storage and android4.4 access storage
In the Android 4.4 system, an external memory card (SD card) is called a secondary external storage device, and applications cannot write data to an external storage card (SD card, in addition, WRITE_EXTERNAL_STORAGE only grants write permission to the primary external storage on the device. For other external storage, the file attributes on it are changed to the folder-based structure, and the application does not need to obtain the WRITE_EXTERNAL_STORAGE permission, however, you can manage folders related to your own package name. For example, if the application package name is com. example. externalstorage, then the Android/data/com. example. externalstorage/folder is its own, which can be accessed at will without permission. In addition, when an application is detached, the corresponding folders and data created on the SD card will be completely deleted at the same time.
In Android 4.4, system applications (applications with a platform signature or pre-installed in the/system/priv-app directory) you can use the WRITE_MEDIA_STORAGE permission to obtain full read/write permissions for the SD card.
Android 4.4 adds the following functions to access external storage:
Context. getExternalFilesDirs (null), returns the files directory of the private data zone of the Application for multiple SD cards.
/Storage/sdcard0/Android/data/<package name>/files /Storage/sdcard1/Android/data/<package name>/files |
Context. getExternalCacheDirs (), return the cache directory of the private database of the application under multiple SD cards
/Storage/sdcard0/Android/data/<package name>/caches /Storage/sdcard1/Android/data/<package name>/caches |
Context. getObbDirs (), returns private data under the obb directory under multiple SD cards (this directory is generally the game's data packet directory)
/Storage/sdcard0/Android/obb/<package name> /Storage/sdcard1/Android/obb/<package name> |
The above function can correctly obtain the path of the SD card on my Android 5.1 system, but only the path of the internal storage can be seen on Android4.4 system.
Based on the information on the Internet, you can manage the SD card by modifying the system file after Android 4.4. The method is as follows:
1 <permission name="android.permission.WRITE_EXTERNAL_STORAGE" >2 <group gid="sdcard_r" />3 <group gid="sdcard_rw" />4 <group gid="media_rw" />5 </permission>
Modify the android. permission. WRITE_EXTERNAL_STORAGE node of the/system/etc/permissions/platform. xml file and add <group gid = "media_rw"/> (root permission required ).
After modification, the app can control the SD card at will.