Cursor cursor = resolver.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, null, null, null,null);
Cursor cursor = resolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null,null);
我想在listview中同时显示出音乐mp3文件和视频mp4文件,怎么把两句话结合??
do {
String name = cursor.getString(cursor
.getColumnIndex(MediaStore.Video.Media.DISPLAY_NAME));// 音乐文件名
long duration = cursor.getLong(cursor
.getColumnIndex(MediaStore.Video.Media.DURATION));
long id = cursor.getLong(cursor
.getColumnIndex(MediaStore.Video.Media._ID));// 时长
String uri = cursor.getString(cursor
.getColumnIndex(MediaStore.Video.Media.DATA));
map.put("name", name);
map.put("path", uri);
map.put("time", duration);
list.add(map);
} while (cursor.moveToNext());
后面的do while循环也要把两部分的循环结合起来。。。谢谢大家
------解决方案--------------------
try
Cursor cursor = new MergeCursor(new Cursor[] {
resolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
null, null, null, null),
resolver.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
null, null, null, null) });
------解决方案--------------------
循环2此,放到一个列表容器中不就好了么