Android : FileProvider on custom external storage folder : <p>I'm trying to set up a fileprovider for sharing file. My files are saved in a folder "AppName" in the external storage (same level as Android, Movies and Pictures folders).</p>

<p>Here is my file provider config :</p>

<pre><code>&lt;provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="com.mydomain.appname.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true"&gt;
    &lt;meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths"/&gt;
&lt;/provider&gt;
</code></pre>

<p>and the file_paths.xml :</p>

<pre><code>&lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;external-path name="mypath" path="AppName" /&gt;
&lt;/paths&gt;
</code></pre>

<p>When i try to access my file with :</p>

<pre><code>Uri fileUri = FileProvider.getUriForFile(activity, "com.mydomain.appname.fileprovider",
            new File("/storage/emulated/0/AppName/IMG_20160419_095211.jpg"));
</code></pre>

<p>It returns an error:
java.lang.IllegalArgumentException: 
Failed to find configured root that contains /storage/emulated/0/AppName/IMG_20160419_095211.jpg
                                                                         at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:678)
                                                                         at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:377)</p>

<p>It worked fine before when I was using built-in directory like Pictures or Movies, my file_paths.xml was define like this :</p>

<pre><code>&lt;external-path name="photos" path="Pictures" /&gt;
&lt;external-path name="videos" path="Movies" /&gt;
</code></pre>

<p>But now I want to store my file in my own folder. Did I miss something with the FileProvider config ?</p>
