【发布时间】:2019-01-18 19:43:28
【问题描述】:
我相信我已经尝试了几乎所有我遇到但无法处理此错误的方法,请有人帮忙。
我的文件存在于文件夹中:
这就是我的内部存储的样子 已编辑:更新的屏幕截图 Internal storage shows that file does exist
我的代码如下:
val intent = Intent(Intent.ACTION_VIEW)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
val uriNew = FileProvider.getUriForFile(this@, "com.thatapp.fileprovider", filePDF)
intent.setDataAndType(uriNew,"application/pdf")
try{
startActivity(intent);
} catch(e:ActivityNotFoundException){
val toast = Toast.makeText(this,"No app found to open the PDF. Please install Adobe Reader",Toast.LENGTH_SHORT)
toast.show()
}
报错如下:
java.lang.IllegalArgumentException:找不到包含 /data/data/com.thatapp.sitereport/app_Site_20180811_112642/Report_20180811_122857.pdf 的配置根目录
最后我的 file_paths 看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="My_Images" path="." />
<files-path
name="Files"
path="/"/>
<!--external-path name="external_files" path="."/-->
</paths>
【问题讨论】:
-
才发现这两个名字不一样。 “存储的一个”和一个用于 uri 的。首先要检查为什么会这样
标签: android uri storage internal