title: Android: App crashes when selecting image from Samsung gallery (but it works with Google Photo app)
body: <p>Good day,</p>
  
  <p>The following code works when I select an image from the Google Photo app. However, when I select the same image from Samsung stock gallery, my app crashes.</p>
  
  <p>I did some troubleshooting and realize the problem is with the <strong>getContentResolver().query()</strong>:</p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data)
  {
      super.onActivityResult(requestCode, resultCode, data);
  
      if (requestCode == PICK_IMAGE &amp;&amp; resultCode == RESULT_OK &amp;&amp; null != data) {
          Uri selectedImage = data.getData();
  
          String[] filePathColumn = { MediaStore.Images.Media.DATA };
  
          //Error happens when program try to run the following line of code
          Cursor cursor = getContentResolver().query(selectedImage,
                  filePathColumn, null, null, null);
  
  
          cursor.moveToFirst();
  
          int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
          String picturePath = cursor.getString(columnIndex);
          cursor.close();
  
          Toast.makeText(getApplicationContext(), picturePath, Toast.LENGTH_LONG).show();
      }
  }
  </code></pre>
  
  <p>Please help me. Thank you.</p>