I struggle to get specific video file details so duration etc. from the file the files recorded earlier. All I can currently do is to get cursor with all the files, then loop one by one.
Cursor cursor = MediaStore.Video.query(getContext().getContentResolver(), MediaStore.Video.Media.EXTERNAL_CONTENT_URI, new String[]{MediaStore.Video.VideoColumns.DURATION,MediaStore.Video.VideoColumns.DATE_TAKEN,MediaStore.Video.VideoColumns.RESOLUTION,MediaStore.Video.VideoColumns.DISPLAY_NAME});
if(cursor.moveToFirst())
while(!cursor.isLast()){
if(cursor.getString(3)==fight.filename)
{
// do something here
}
cursor.moveToNext();
}
I need however to access details of specific files so I tried to create URI but no luck as cursor returned is always null. Where do I go wrong?
Uri uri = Uri.parse(Environment.DIRECTORY_DCIM+"/FightAll_BJJ_Scoring/"+(fight.filename));
Cursor cursor = MediaStore.Video.query(getContext().getContentResolver(), uri, new String[]{MediaStore.Video.VideoColumns.DURATION,MediaStore.Video.VideoColumns.DATE_TAKEN,MediaStore.Video.VideoColumns.RESOLUTION,MediaStore.Video.VideoColumns.DISPLAY_NAME});
// cursor is always null here