How can i get list of all videos on sd card? I just started learning android, and I want to create simple video player (I want to put videos from sd card in grid view). My guess is I should recursively scan all directories and filter video files, am I right? I could easily do it in java but maybe there is some dedicated tool in android?
Asked
Active
Viewed 9,170 times
1 Answers
8
Query the MediaStore
content provider
http://developer.android.com/reference/android/provider/MediaStore.html
An example could be
public static void printNamesToLogCat(Context context) {
Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
String[] projection = { MediaStore.Video.VideoColumns.DATA };
Cursor c = context.getContentResolver().query(uri, projection, null, null, null);
int vidsCount = 0;
if (c != null) {
vidsCount = c.getCount();
while (c.moveToNext()) {
Log.d("VIDEO", c.getString(0));
}
c.close();
}
}

Vrashabh Irde
- 14,129
- 6
- 51
- 103
-
using MediaStore how to retrive videos from subfolder.. I get all folder from the sdcard containing videos.. but how to get the subfolder containing videos. – Muhammad Tufail Dec 28 '17 at 09:25
-