天天看点

android 获取sd卡视频文件名,android – 如何获取SD卡上的视频列表

查询MediaStore内容提供商

一个例子可能是

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();

}

}