title: Invalid URI exception in DocumentsContract.getDocumentId (uri)
body: <p>I am trying to get the document id of the image which I saved, I am saving the image file to the following external storage in the device.</p>
  
  <pre><code>file:///storage/emulated/0/Pictures/BeautifulFaces/kvh_20160420T225141.jpg
  </code></pre>
  
  <p>After querying querying </p>
  
  <pre><code>public String checkIfImageIsRotated(Uri image_uri){
  
      Log.i(LOG_TAG, "&gt;&gt;&gt;&gt;&gt; START ");
      int rotation =0;
      String[] selection = new String[] { MediaStore.Images.Media._ID,
                                          MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
                                          MediaStore.Images.Media.DATA,
                                          MediaStore.Images.Media.DATE_TAKEN,
                                          MediaStore.Images.Media.ORIENTATION};
  
      String selectionArgs = MediaStore.Images.Media.BUCKET_DISPLAY_NAME +  " = ?";
      String[] args = new String[]{FOLDER_NAME};
      String sortOrder = MediaStore.Images.Media.DATE_TAKEN + " DESC";
  
      ContentResolver content = mContext.getContentResolver();
      Cursor mediaCursor = content.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                                          selection ,
                                          selectionArgs,
                                          args,
                                  sortOrder);
  
      //select of columns
      //MediaStore.Images.ImageColumns.ORIENTATION
      //MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME
      if (mediaCursor != null &amp;&amp; mediaCursor.getCount() !=0 ) {
          if(mediaCursor.moveToNext()){
              Log.i(LOG_TAG, "&gt;&gt;&gt;&gt;&gt; media cursor not null ");
              String orientation = mediaCursor.getString(4);
              String bucket_display_name = mediaCursor.getString(1);
              image_data_path = mediaCursor.getString(2);
              Log.i(LOG_TAG, "&gt;&gt;&gt;&gt;&gt; rotation -  " + orientation + ", bucket display name - " + bucket_display_name + ", data - " + image_data_path);
          }
  
          mediaCursor.close();
      }
  
      Log.i(LOG_TAG, "&gt;&gt;&gt;&gt;&gt; END ");
      return image_data_path;
  }
  </code></pre>
  
  <p>image_data_path is </p>
  
  <pre><code>/storage/emulated/0/Pictures/BeautifulFaces/kvh_20160420T225141.jpg
  </code></pre>
  
  <p>Now when I am trying to do DocumentsContract.getDocumentId(uri) where uri is either the file uri mentioned at the top or image_data_path returned from the cursor, in both cases I am getting the following error.</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: Invalid URI: file:///storage/emulated/0/Pictures/BeautifulFaces/kvh_20160420T225141.jpg
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: Invalid URI: /storage/emulated/0/Pictures/BeautifulFaces/kvh_20160420T225141.jpg
  </code></pre>
  
  <p>Cannot understand why Document.getDocumentId is not able to parse the Uri.</p>
  
  <p>Thanks</p>