Android 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 标签

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

 

    原文作者:星辰之力
    原文地址: https://www.cnblogs.com/zhujiabin/p/7843974.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞