Android: FileProvider IllegalArgumentException Failed to find configured root that contains /data/data/**/files/Videos/final.mp4

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.

Go with:

    <files-path name="my_docs" path="Videos/" />

change your provider XML to this.

<?xml version="1.0" encoding="utf-8"?>
  <external-path name="external_files" path="." />
  <root-path name="external_files" path="/storage/" />

I had the very same basic situation. I defined everything correctly (files-path in xml) but there is one more thing which leads to the same exception. I add another answer just as an addition and a comment would not be well readable.

I created/read the directory where i store the files like:

context.getDir("Documents", Context.MODE_PRIVATE) 

This leads to a path like:


Then i changed creating the directory to:

File directory = new File(context.getFilesDir(), "Documents");
if (!directory.exists()) {

This leads to a path like:


According to the documentation Open a directory the two methods should be equivalent as far as i understand it. But it creates a different path… Maybe the formulation is just not clear for me in the documentation, but for me its wrongly written.

getDir(name, mode)

Creates a new directory (or opens an existing directory) within your
app’s unique file system directory. This new directory appears inside
the directory provided by getFilesDir().

Leave a Comment