title: File not found exception (Path from URI)
body: <p>I'm trying to get a <code>FileInputStream</code> object for the picture a user selects from their gallery and when I'm trying to open the file from the URI I receive, it keeps saying <code>FileNotFoundException</code>...</p>
  
  <p>Here's the code I'm using to fire off the intent for picking an image from the gallery:</p>
  
  <pre><code>Intent intent = new Intent();
      intent.setType("image/*");
      intent.setAction(Intent.ACTION_GET_CONTENT);
      startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
  </code></pre>
  
  <p>And here's the code I use for catching <code>onActivityResult</code>:</p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
  
      if (requestCode == PICK_IMAGE_REQUEST &amp;&amp; resultCode == RESULT_OK &amp;&amp; data != null &amp;&amp; data.getData() != null) {
  
          Uri uri = data.getData();
          File myFile = new File(uri.getPath());
          FileInputStream fiStream = new FileInputStream(myFile);
          ...
      }
  
  }
  </code></pre>
  
  <p>Right on the creation of the <code>FileInputStream</code>, I get the folloiwng error upon choosing one of my photos via the emulator:</p>
  
  <pre><code>W/System.err: java.io.FileNotFoundException: /document/image:26171: open failed: ENOENT (No such file or directory)
  </code></pre>
  
  <p>Maybe I'm retrieving the file from the URI incorrectly??? Any help here would be greatly appreciated, thanks!!</p>
  
  <h2>Solution</h2>
  
  <p>I ended up using <a href="https://android-arsenal.com/details/1/2725" rel="noreferrer">https://android-arsenal.com/details/1/2725</a>
  It's very easy to use!</p>