`

Failed to ensure directory问题

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



在android4.0源码出来以后,关于sd卡问题似乎没有解决好,起码上层api中没有体现到位。其实在framework层中有相应的类去获得内外置sd卡信息,是否可读写的权限。
     在2.x的版本中,在manifest中配置的权限android.permission.WRITE_EXTERNAL_STORAGE确实是用来使得sd卡获得写的权限。而在4.0开发的源码当中,由于有了内外置sd卡的区分,android.permission.WRITE_EXTERNAL_STORAGE的权限用来设置了内置sd卡的写权限,如果在manifest中只是配置了这个权限,那个应用只能在内置sd卡中进行写操作,还是无法在外置sd卡中进行写操作。需要写外置sd卡的话,需要配置另一个权限android.permission.WRITE_MEDIA_STORAGE,这样就可以在外置sd卡中进行写入操作了。
这两个权限都被定义在android源码目录\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>
分享到:
评论

相关推荐

    BURNINTEST--硬件检测工具

    - Added additional USB 2.0 Loopback plug test initialization to ensure plugs are in a 'clean' state when starting the USB tests. This was added due to reported USB data verification errors after ...

    Git-2.21.0-64-bit.zip

    ought to be relative to the directory "git init" gets invoked in, but it instead was made relative to the repository, which has been corrected. * "git worktree add" used to fail when another work...

    ota打包及升级问题汇总

    1. **报错:“cp:cannot stat ‘kernel/resource.img’: No such file or directory”** - **问题描述**:当尝试使用`make otapackage`命令进行打包时,可能会遇到此错误提示。该错误通常出现在那些不会自动生成`...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    All of a project's header files should be listed as descentants of the project's source directory without use of UNIX directory shortcuts . (the current directory) or .. (the parent directory). For...

    php.ini-development

    apply to PHP files in the /www/mysite directory. Directives ; following the section heading [HOST=www.example.com] only apply to ; PHP files served from www.example.com. Directives set in these ; ...

    acpi控制笔记本风扇转速

    Added #pragma pack(8/4) to acobject.h to ensure that the structures in this header are always compiled as aligned. The ACPI_OPERAND_OBJECT has been manually optimized to be aligned and will not work ...

    ansible安装k8s,1.25

    - name: Copy kubeconfig to user's home directory become: yes copy: src: /etc/kubernetes/admin.conf dest: ~/.kube/config remote_src: yes notify: Source kubeconfig - meta: flush_handlers - name:...

    CIS_Solaris_10_Benchmark_v5.0.0

    Create /opt/CIS Directory (optional) .......................................................................................... 12 Benchmark Items ........................................................

Global site tag (gtag.js) - Google Analytics