title: java.lang.IllegalArgumentException: Failed to find configured root that contains /file:/
body: <p>I am trying to open the file downloaded by <code>DownloadManager</code>. I registered a <code>BroadcastReceiver</code> with action <code>DownloadManager.ACTION_DOWNLOAD_COMPLETE</code>.</p>
  
  <p>Here's the <code>onReceive</code> method of my receiver-  </p>
  
  <pre><code>try {
      DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
      long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
  
      DownloadManager.Query query = new DownloadManager.Query();
      query.setFilterById(downloadId);
  
      Cursor c = dm != null ? dm.query(query) : null;
      Log.d("Cursor", String.valueOf(c));
      String uri = null;
      if (c != null &amp;&amp; c.moveToFirst()) {
          uri = c.getString(c.getColumnIndex("local_uri"));
      }
      Log.d("URI", uri);
  
      Intent open = new Intent(Intent.ACTION_VIEW);
      open.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
  
      //Get mime type
      String mimeType = "*/*";
      String extension = null;
      extension = MimeTypeMap.getFileExtensionFromUrl(uri);
      if (extension != null) {
          mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
      }
  
      //Set data and start activity  
      open.setDataAndType(FileProvider.getUriForFile(getApplicationContext(), getPackageName() + ".provider", new File(Uri.parse(uri).getPath())), mimeType);    //It shows error at this line 
      startActivity(install);
  } catch (Exception e) {
      e.printStackTrace();
  }  
  </code></pre>
  
  <p>Here is the <code>provider</code> tag in my <code>AndroidManifest.xml</code> file -</p>
  
  <pre><code>&lt;provider
      android:name="android.support.v4.content.FileProvider"
      android:authorities="${applicationId}.provider"
      android:exported="false"
      android:grantUriPermissions="true"&gt;
      &lt;meta-data
          android:name="android.support.FILE_PROVIDER_PATHS"
          android:resource="@xml/provider_paths"/&gt;
  &lt;/provider&gt;  
  </code></pre>
  
  <p>And the <code>provider_paths.xml</code> file -  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;external-files-path
          name="external_files"
          path="/"/&gt;
  &lt;/paths&gt;  
  </code></pre>
  
  <p>But when I run my app, it shows this error when it tries to open the file:<br>
  <code>java.lang.IllegalArgumentException: Failed to find configured root that contains /file:/storage/emulated/0/...</code>    (the uri)  </p>
  
  <p>The complete stack trace looks like this :  </p>
  
  <pre><code>01-14 20:49:49.069 21296-21296/in.edu.jaduniv.classroom W/System.err: java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/Classroom/juit1620/Syllabus/1405929814-1-14.pdf
  01-14 20:49:49.070 21296-21296/in.edu.jaduniv.classroom W/System.err:     at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:719)
  01-14 20:49:49.070 21296-21296/in.edu.jaduniv.classroom W/System.err:     at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:404)
  01-14 20:49:49.070 21296-21296/in.edu.jaduniv.classroom W/System.err:     at in.edu.jaduniv.classroom.activity.Syllabus$2.onReceive(Syllabus.java:149)
  01-14 20:49:49.070 21296-21296/in.edu.jaduniv.classroom W/System.err:     at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:1122)
  01-14 20:49:49.070 21296-21296/in.edu.jaduniv.classroom W/System.err:     at android.os.Handler.handleCallback(Handler.java:751)
  01-14 20:49:49.070 21296-21296/in.edu.jaduniv.classroom W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
  01-14 20:49:49.070 21296-21296/in.edu.jaduniv.classroom W/System.err:     at android.os.Looper.loop(Looper.java:154)
  01-14 20:49:49.070 21296-21296/in.edu.jaduniv.classroom W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6123)
  01-14 20:49:49.070 21296-21296/in.edu.jaduniv.classroom W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
  01-14 20:49:49.070 21296-21296/in.edu.jaduniv.classroom W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
  01-14 20:49:49.070 21296-21296/in.edu.jaduniv.classroom W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
  01-14 20:50:21.336 21296-21358/in.edu.jaduniv.classroom W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
  01-14 20:54:02.582 21296-23083/in.edu.jaduniv.classroom D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=338004, firebase_screen_class(_sc)=Syllabus, firebase_screen_id(_si)=-6138131816728422160}]
  01-14 20:54:02.611 21296-23083/in.edu.jaduniv.classroom D/FA: Connected to remote service
  </code></pre>
  
  <p>What should I do?<br>
  Thanks!</p>