【发布时间】:2017-01-13 17:48:38
【问题描述】:
我正在尝试获取这样的文件的 URI:
Uri photoURI = FileProvider.getUriForFile(this,
"br.com.[blablabla].sgaconsultor",
createImageFile());
private File createImageFile() throws IOException {
// Create an image file name
String imageFileName = "registroFoto";
ContextWrapper cw = new ContextWrapper(getApplicationContext());
File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
return File.createTempFile(
imageFileName, /* prefix */
".jpg", /* suffix */
directory
);
}
我有一个文件提供者:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="br.com.[blablabla].blabla"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
xml 是:
<paths>
<files-path name="br.com.[blablabla].blabla" path="app_imageDir" />
</paths>
但是当我运行这段代码时,我总是得到这个错误:
java.lang.IllegalArgumentException:Android: FileProvider IllegalArgumentException Failed to find configured root that contains /data/data/**/files/Videos/final.mp4
但到目前为止还没有运气...... 那么我该如何解决这个问题并获取我的文件的 URI?
非常感谢任何帮助!
【问题讨论】:
标签: java android image storage