English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Android4.4 accessing external storage
in Android 4.4in the system, the external storage card (SD card) is called a secondary external storage device (secondary storage), and the application is unable to write data to the external storage card (SD card). Moreover, WRITE_EXTERNAL_STORAGE only grants write permission to the primary external storage (primary storage) on the device, and for other external storage, the file attributes are all changed to be based on the folder structure. The application does not need to obtain the WRITE_EXTERNAL_STORAGE permission, but can manage the folders related to its package name. For example, if the package name of the application is com.example.externalstorage, then the Android/data/com.example.externalstorage/the folder is its own, accessible at will, without permission. In addition, it should be especially noted that when the application is uninstalled, the corresponding folders and data created on the SD card will be completely deleted at the same time.
exception, in Android 4.4inside, the system application (referring to applications with platform signature or pre-installed/system/priv-The application under the app directory can obtain full read and write permissions to the SD card by using the WRITE_MEDIA_STORAGE permission.
Android 4.4The following function has been added to access external storage:
Context.getExternalFilesDirs(null), returns multiple files directories under the private data area of the application on the SD card
/storage/sdcard0/Android/data/<package name>/files
/storage/sdcard1/Android/data/<package name>/files
Context.getExternalCacheDirs(), returns multiple cache directories under the private database of the application on the SD card
/storage/sdcard0/Android/data/<package name>/caches
/storage/sdcard1/Android/data/<package name>/caches
Context.getObbDirs(), returns multiple private data directories under the obb directory of the SD card (this directory is generally the data package directory of the game)
/storage/sdcard0/Android/obb/<package name>
/storage/sdcard1/Android/obb/<package name>
Through the above function in my Android 5.1system can correctly obtain the SD card path, but in Android4.4system, only the path of internal storage can be seen.
According to online information, on the Android 4.4You can manage the SD card by modifying system files in the future. 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/system/etc/permissions/Add <group gid="media_rw"> to the android.permission.WRITE_EXTERNAL_STORAGE node in the platform.xml file. /( Requires root permissions ).
After modifying, apply the settings and you can control the SD card freely.
Thank you for reading, I hope it can help everyone, thank you for your support to this site!