Failed to ensure directory problem

04-19 14:38:08.868: W/ContextImpl(17290): Failed to ensure directory: /storage/sdcard1/Android/data/xxxx/files/xxx-cache



After the android4.0 source code comes out, it seems that the sd card problem It has not been solved, at least it is not reflected in the upper-level api. In fact, there is a corresponding class in the framework layer to obtain the internal and external SD card information, whether it can read and write permissions.
     In the 2.x version, the permission android.permission.WRITE_EXTERNAL_STORAGE configured in the manifest is indeed used to make the sd card write permission. In the source code developed in 4.0, due to the distinction between internal and external sd cards, the android.permission.WRITE_EXTERNAL_STORAGE permission is used to set the write permission of the built-in sd card. If only this permission is configured in the manifest, the application can only The write operation is performed in the built-in sd card, but the write operation cannot be performed in the external sd card. If you need to write to the external sd card, you need to configure another permission android.permission.WRITE_MEDIA_STORAGE, so that you can write to the external sd card.
Both permissions are defined in the android source directory \frameworks\base\data\etc\platform.xml:

    <permission name="android.permission.WRITE_EXTERNAL_STORAGE" >

    <group gid="sdcard_rw" />

    </permission>

    <permission name="android.permission.WRITE_MEDIA_STORAGE" >

    <group gid="media_rw" />

    </permission>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326859422&siteId=291194637