title: Android - Picker to select multiple videos
body: <p>I've tried using a simple Activity to select multiple videos, but the file paths I get are always null. Even though I get the URI like :</p>
  
  <p>"content://com.android.providers.media.documents/document/video%3A86935"</p>
  
  <p>I cannot convert this into a filePath. With the code below, "videoPath is null" will be always printed.</p>
  
  <pre><code>public class VideoPickerActivity extends Activity {
  
      private static final String TAG = "VideoPickerActivity";
  
      private static final int SELECT_VIDEO = 1;
  
      private List&lt;String&gt; selectedVideos;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          Intent intent = new Intent();
          intent.setType("video/mp4");
          intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
          intent.setAction(Intent.ACTION_GET_CONTENT);
          startActivityForResult(Intent.createChooser(intent, "Select videos"), SELECT_VIDEO);
      }
  
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          if (resultCode == RESULT_OK) {
              if (requestCode == SELECT_VIDEO) {
                  selectedVideos = getSelectedVideos(data);
              }
          }
          finish();
      }
  
      private List&lt;String&gt; getSelectedVideos(Intent data) {
  
          List&lt;String&gt; result = new ArrayList&lt;&gt;();
  
          String[] filePathColumn = { MediaStore.Video.Media.DATA };
  
          // Single video selected
          if(data.getData() != null){
  
              Uri mImageUri = data.getData();
  
              // Get the cursor
              Cursor cursor = getContentResolver().query(mImageUri,
                      filePathColumn, null, null, null);
              // Move to first row
              cursor.moveToFirst();
  
              int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
              String videoPath  = cursor.getString(columnIndex);
              if(videoPath == null)
                  Log.e(TAG, "videoPath is null");
              result.add(videoPath);
              cursor.close();
          }
          // Multiple videos selected
          else {
              ClipData mClipData = data.getClipData();
              if (mClipData != null) {
                  for (int i = 0; i &lt; mClipData.getItemCount(); i++) {
  
                      ClipData.Item item = mClipData.getItemAt(i);
                      Uri uri = item.getUri();
                      // Get the cursor
                      Cursor cursor = getContentResolver().query(uri, filePathColumn, null, null, null);
                      // Move to first row
                      if (cursor == null)
                          Log.e(TAG, "cursor is null");
                      else {
                          if (cursor.moveToFirst()) {
                              int columnIndex = cursor.getColumnIndex(MediaStore.Video.Media.DATA);
                              String videoPath = cursor.getString(columnIndex);
                              if(videoPath == null)
                                  Log.e(TAG, "videoPath is null");
                              result.add(videoPath);
                          } else {
                              Log.e(TAG, "cannot use cursor");
                          }
                          cursor.close();
                      }
                  }
              }
          }
  
          return result;
      }
  }
  </code></pre>
  
  <p>Any help would be appreciated, thanks !</p>