title: Android: Get video from Gallery uri
body: <p>I'm trying to get a video from the Android Gallery and get the full path, so I can upload the video in an app...</p>
  
  <p>I'm displaying the gallery like this:</p>
  
  <pre><code>Intent intent = new Intent();
  intent.setType("video/*");
  intent.setAction(Intent.ACTION_GET_CONTENT);
  activity.startActivityForResult(Intent.createChooser(intent, context.getResources().getString(R.string.popup_menu_share_video_title)), Const.PICK_VIDEO_REQUEST);
  </code></pre>
  
  <p>I then extract the uri:</p>
  
  <pre><code>Uri selectedUri = data.getData();
  String selectedPath = getRealPathFromURI(this, selectedUri);
  </code></pre>
  
  <p>And attempt to get the path:</p>
  
  <pre><code>public String getRealPathFromURI(Context context, Uri contentUri) {
      Cursor cursor = null;
      try {
          String[] proj = { MediaStore.Video.Media.DATA };
          cursor = context.getContentResolver().query(contentUri,  proj, null, null, null);
          int column_index = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
          cursor.moveToFirst();
          return cursor.getString(column_index);
      } finally {
          if (cursor != null) {
              cursor.close();
          }
      }
  }
  </code></pre>
  
  <p>But I can't seem the get the path...</p>
  
  <p>I can see all the videos if I do this:</p>
  
  <pre><code>public static void dumpVideos(Context context ) {
      Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
      String[] projection = { MediaStore.Video.Media.DATA };
      Cursor c = context.getContentResolver().query(uri, projection, null, null, null);
      int vidsCount = 0;
      if (c != null) {
          vidsCount = c.getCount();
          while (c.moveToNext()) {
              Log.d("VIDEO", c.getString(0));
          }
          c.close();
      }
      Log.d("VIDEO", "Total count of videos: " + vidsCount);
  }
  </code></pre>
  
  <p>So I'm thinking there must be some real simple step, that I'm missing...</p>