Created
March 18, 2018 18:35
-
-
Save valterh4ck3r/7346473d2ecc86663215f8c4d95f9394 to your computer and use it in GitHub Desktop.
Get Path from Video Intent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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