【Android】【Other】FileProvider相关 Failed to find configured root that contains

问题:

使用FileProvider构造SD卡中文件uri时异常

java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/840E-10F6/音乐/千里之外.mp3
at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:678)
at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:377)


解决方案:

provider_paths.xml 中增加 root-path 标签

xmlns:android="http://schemas.android.com/apk/res/android">
    
            name="root_path"
        path="." />


附:

http://www.jianshu.com/p/121bbb07cb07










你可能感兴趣的:(--Android,------Other)