title: Android - save video with content provider
body: <p>I try to save an video to sd card. To test my codes, I save the selected video from gallery to another folder.</p>
  
  <p>I call gallery intent, and pick a video. onActivityResult function code is below : </p>
  
  <pre><code>if(requestCode == VIDEO_PICK) {
          if (resultCode == RESULT_OK) {
              try {
                  String path = getRealPathFromURI(data.getData());
                  Log.i("@@Path ", " " + path);
  
                  File file = new File(new URI(path));
                  Uri uri = addVideo(file);
              } catch(Exception err) {
                  Log.i("@@Exception", " " + err);
              }
          }
  }
  
  public Uri addVideo(File videoFile) {
      ContentValues values = new ContentValues();
      values.put(MediaStore.Video.Media.TITLE, "My video title");
      values.put(MediaStore.Video.Media.MIME_TYPE, "video/mp4");
      values.put(MediaStore.Images.Media.DISPLAY_NAME, "player");
      values.put(MediaStore.Images.Media.DESCRIPTION, "");
      values.put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis());
      values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis());
      values.put(MediaStore.Video.Media.DATA, videoFile.getAbsolutePath());
  
      return getActivity().getContentResolver().insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values);
  
  }
  </code></pre>
  
  <p>addVideo function throws an exception. </p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: URI is not absolute: </p>
  </blockquote>
  
  <p>How can I get absolute path from uri? I tried uri.toString() and uri.getPath(). They didn't work.</p>
  
  <p>getRealPathFromUri implementation is <a href="https://stackoverflow.com/questions/3401579/get-filename-and-path-from-uri-from-mediastore?rq=1">here</a></p>