@Nullable
  public static String getRealPathFromUri(ContentResolver contentResolver, final Uri srcUri) {
    String result = null;
    Uri uri = srcUri;
    String mimeTypeString = contentResolver.getType(uri);
    if (isLocalContentUri(uri)) {
      boolean isVideo = mimeTypeString != null && mimeTypeString.startsWith("video/");
      String selection = null;
      String[] selectionArgs = null;
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
          && "com.android.providers.media.documents".equals(uri.getAuthority())) {
        String documentId = DocumentsContract.getDocumentId(uri);
        Preconditions.checkNotNull(documentId);
        uri = Preconditions.checkNotNull(getExternalContentUri(isVideo));
        selection = getMediaIdString(isVideo) + "=?";
        selectionArgs = new String[] {documentId.split(":")[1]};
      }
      Cursor cursor =
          contentResolver.query(
              uri, new String[] {getDataPathString(isVideo)}, selection, selectionArgs, null);
      try {
        if (cursor != null && cursor.moveToFirst()) {
          int idx = cursor.getColumnIndexOrThrow(getDataPathString(isVideo));
          if (idx != -1) {
            result = cursor.getString(idx);
          }
        }
      } finally {
        if (cursor != null) {
          cursor.close();
        }
      }
    } else if (isLocalFileUri(uri)) {
      result = uri.getPath();
    }
    return result;
  }
Get the path of a file from the Uri.

@param contentResolver the content resolver which will query for the source file
@param srcUri The source uri
@return The Path for the file or null if doesn't exists
fbcore/src/main/java/com/facebook/common/util/UriUtil.java