本文介绍了Android:FileProvider IllegalArgumentException无法找到包含/data/data/**/files/Videos/final.mp4的配置根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 FileProvider
从私有路径播放视频.
I am trying to use FileProvider
to play a video from private path.Facing
java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/XXXXX(Package)/files/Videos/final.mp4
代码:
<paths>
<files-path path="my_docs" name="Videos/" />
</paths>
Java代码:
File imagePath = new File(getFilesDir(), "Videos");
File newFile = new File(imagePath, "final.mp4");
Log.d(TAG, "-------------newFile:"+newFile.exists());//True here
//Exception in below line
Uri contentUri = FileProvider.getUriForFile(this,"com.wow.fileprovider", newFile);
Manifest.xml
Manifest.xml
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.wow.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
有任何线索吗?
谢谢尼兹
推荐答案
您的名称
和 path
被翻转了. name
是 Uri
中的内容, path
是文件系统根中的相对位置.
You have your name
and your path
flipped. name
is what goes in the Uri
, and path
is the relative location within the root on the filesystem.
继续:
<paths>
<files-path name="my_docs" path="Videos/" />
</paths>
这篇关于Android:FileProvider IllegalArgumentException无法找到包含/data/data/**/files/Videos/final.mp4的配置根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!