Skip to content

Instantly share code, notes, and snippets.

@valterh4ck3r
Created March 18, 2018 18:35
Show Gist options
  • Save valterh4ck3r/7346473d2ecc86663215f8c4d95f9394 to your computer and use it in GitHub Desktop.
Save valterh4ck3r/7346473d2ecc86663215f8c4d95f9394 to your computer and use it in GitHub Desktop.
Get Path from Video Intent
public static String getPath(Uri uri , Context context) {
String[] projection = { MediaStore.Video.Media.DATA };
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
if (cursor != null) {
// HERE YOU WILL GET A NULLPOINTER IF CURSOR IS NULL
// THIS CAN BE, IF YOU USED OI FILE MANAGER FOR PICKING THE MEDIA
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} else
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment