How to get all videos on Android device

android

Solution

If someone is still looking for answer please Try this method. This method will return list of path of all media.

public ArrayList<String> getAllMedia() {
    HashSet<String> videoItemHashSet = new HashSet<>();
    String[] projection = { MediaStore.Video.VideoColumns.DATA ,MediaStore.Video.Media.DISPLAY_NAME};
    Cursor cursor = getContext().getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
    try {
        cursor.moveToFirst();
        do{
            videoItemHashSet.add((cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA))));
        }while(cursor.moveToNext());

        cursor.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    ArrayList<String> downloadedList = new ArrayList<>(videoItemHashSet);
    return downloadedList;
}

Problem

How can I get a list of all videos and their path that can be found on an Android device where is my app installed? EDIT: I am trying to make a simple video player, so the idea would be to display all the videos that can be found on the device and to play it on list item click. Only problem is that i don't know how to get that info about videos, so I would be very thankful if someone can help me.

Original source

Related problems