I am trying to get the URI for a file like this:
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
);
}
I have a file provider:
<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>
And the xml is:
<paths>
<files-path name="br.com.[blablabla].blabla" path="app_imageDir" />
</paths>
But when I run this code I always get this error:
java.lang.IllegalArgumentException: Android: FileProvider IllegalArgumentException Failed to find configured root that contains /data/data/**/files/Videos/final.mp4
But no luck so far... So how can I fix this and get the URI for my file?
Any help is really appreciated!