title: How to open files (from SD-Card) in gallery
body: <p>I save paths of different jpg. files in a database. These images are partly in the internal memory and partly in the external memory (SD-card).</p>
  
  <p>Now I want to open the pictures in the gallery.
  To open images from the internal memory I use the FileProvider, I proceed as follows:</p>
  
  <pre class="lang-java prettyprint-override"><code>String path = "/storage/emulated/0/Pictures/Meetings/IMG_Testmeeting20180809_225414.jpg";
  
  File image = new File(path);
  Uri uri = FileProvider.getUriForFile(getContext(), "com.meetings.martin.provider",image);
  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.setDataAndType(uri, "image/*");
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  getContext().startActivity(intent);
  </code></pre>
  
  <p>This is my FileProvider in the AndroidManifest.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;provider
      android:name="android.support.v4.content.FileProvider"
      android:authorities="com.meetings.martin.provider"
      android:exported="false"
      android:grantUriPermissions="true"&gt;
      &lt;meta-data
          android:name="android.support.FILE_PROVIDER_PATHS"
          android:resource="@xml/file_paths"&gt;
      &lt;/meta-data&gt;
  &lt;/provider&gt;
  </code></pre>
  
  <p>This is content of the file_paths.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code> &lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;external-path name="my_images" path="." /&gt;
  &lt;/paths&gt;
  </code></pre>
  
  <p>This works perfectly..
  ..but , if I want to open an image, which is located on the SD card, I get the following error message:</p>
  
  <pre><code>Failed to find configured root that contains &lt;path&gt;
  </code></pre>
  
  <p>I've often read that the FileProvider can not access files on the SD card. <strong>But how can I then turn the path into a Uri and open it in the gallery?</strong></p>