title: ACTION_PICK with MediaStore.Images.Media.INTERNAL_CONTENT_URI allowing users to pick images synced via picasa (not on device?)
body: <p>I was testing our app on a tablet and phone both running ICS and using the same Google account. If I take a photo on one it will show up on the other device (syncing via Picasa). The weird thing is that photo shows up on both devices when I do the normal </p>
  
  <pre><code>Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
  </code></pre>
  
  <p>to let the user pick an image from the gallery. My onActivityResult() looks like this:</p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (resultCode != Activity.RESULT_OK) {
          return; // user cancelled
      }
  
      Uri imageUri = data.getData();
      if (imageUri == null) {
          // (code to show error message goes here)
          return;
      }
  
      // Get image path from media store
      String[] filePathColumn = { android.provider.MediaStore.MediaColumns.DATA };
      Cursor cursor = this.getContentResolver().query(imageUri, filePathColumn, null, null, null);
  
      if(cursor == null || !cursor.moveToFirst()) {
          // (code to show error message goes here)
          return;
      }
  
      int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
      String imagePath = cursor.getString(columnIndex);
      cursor.close();
  
      if (imagePath == null) {
          // error happens here
      }
  }
  </code></pre>
  
  <p>Everything is fine until the end when imagePath is null. The code works perfectly for other photos on the device but not the synced one. After adding a bit of logging code it looks like this is happening to some of our users in production, albeit very rarely (less than 1 out of 10,000 photos).</p>
  
  <p>I understand that ACTION_GET_CONTENT has the EXTRA_LOCAL_ONLY flag to only show local files, but this is only available on API version 11 and up. ACTION_GET_CONTENT also has  CATEGORY_OPENABLE to only show data that can be opened. Is my ACTION_PICK intent somehow (incorrectly?) showing photos that aren't actually local or openable? According to the documentation, using INTERNAL_CONTENT_URI is only supposed show photos stored internally.</p>
  
  <p>Or are there any issues with my onActivityResult() code? I've seen a ton of different variations:</p>
  
  <ul>
  <li>checking to make sure data.getData().getPath() isn't null</li>
  <li>using MediaStore.Images.Media.DATA as the projection instead of MediaStore.MediaColumns.DATA</li>
  <li>using MediaStore.Images.ImageColumns.DATA as the projection instead of MediaStore.MediaColumns.DATA</li>
  <li>using managedQuery() to get the Cursor instead of getContentResolver().query()</li>
  <li>using CursorLoader to get the Cursor (API 11+)</li>
  <li>using getColumnIndexOrThrow() instead of getColumnIndex()</li>
  <li>calling cursor.getColumnIndex(MediaStore.Images.Media.DATA) and THEN calling cursor.moveToFirst()</li>
  <li>using "userImage" as the column name (parameter for getColumnIndex())</li>
  </ul>
  
  <p>Would any of these changes fix the problem?</p>