The content://media/external/video/media/ is URI type and you need to query MediaStore to get full path name to the file.
Something like below:
public static String getFilePathFromContentUri(Uri selectedVideoUri,
ContentResolver contentResolver) {
String filePath;
String[] filePathColumn = {MediaColumns.DATA};
Cursor cursor = contentResolver.query(selectedVideoUri, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
try {
filePath = cursor.getString(columnIndex);
} catch (Exception e) {
// TODO Auto-generated catch block
//e.printStackTrace();
//Need this in case the file not exist
return null;
}
cursor.close();
return filePath;
}
No comments:
Post a Comment