title: Getting path from Uri from Google Photos app
body: <p>I have an app which allows to select photos with an external app. Then I take the path of the photo from the uri and use it for internal actions.</p>
  
  <p>When user selects a photo with Google Photo, if the picture is locally stored then the next code works perfectly. But if the picture is in the cloud the result of <em>cursor.getString(index)</em> is null.</p>
  
  <p>I've search for some info, but not sure about the solution</p>
  
  <pre><code>final String[] projection = { "_data" };
  Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
  
  if (cursor != null &amp;&amp; cursor.moveToFirst()) {
      final int index = cursor.getColumnIndexOrThrow("_data");
      return cursor.getString(index);
  }
  </code></pre>
  
  <p>Thank you!</p>