文件提供程序错误 "Failed to find configured root that contains /data/data/sawbodeployer.entm.illinois.edu ..."

FileProvider error "Failed to find configured root that contains /data/data/sawbodeployer.entm.illinois.edu ..."

我通过 android 下载管理器下载视频并想分享这个视频,我关注 Manifas

 <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="my.domain"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/paths" />
    </provider>

并在文件 path.xml 中添加:

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

并使用此提供商:

File file = new File(getActivity().getFilesDir() , videoPath);
                Uri uri = FileProvider.getUriForFile(getContext(), "my.domain", file);
                Intent intent = ShareCompat.IntentBuilder.from(getActivity())
                        .setType("video/3gp")
                        .setStream(uri)
                        .setChooserTitle("Choose bar")
                        .createChooserIntent()
                        .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                startActivity(intent);

但我收到错误:

java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/sawbodeployer.entm.illinois.edu/files/AKA1_Fante_Ghana_HandWashing_Final.3gp

它的问题在哪里?

替换:

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

与:

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

path 在根目录下有一些特定的子目录时使用。您的文件直接在 getFilesDir() 中,因此您不能使用 path.