我正在尝试使用以下代码在图库中显示所有视频,
String[] proj = { MediaStore.Video.Media._ID,MediaStore.Video.Media.DATA,MediaStore.Video.Media.DISPLAY_NAME,MediaStore.Video.Media.SIZE };
videocursor = managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,proj, null,null, null);
int count = videocursor.getCount();
但我总是得到count = 0
,我在哪里弄错了?
我也试过
Cursor videocursor = managedQuery(MediaStore.Video.Media.INTERNAL_CONTENT_URI, proj, null, null, null);
答案 0 :(得分:0)
这样做 -
String[] proj = { MediaStore.Video.Media.DATA,
MediaStore.Video.Media._ID, MediaStore.Video.Media.TITLE,
MediaStore.Video.Media.DISPLAY_NAME,
MediaStore.Video.Media.MIME_TYPE,
MediaStore.Video.Media.DURATION,
MediaStore.Video.Media.SIZE,};
String orderBy = android.provider.MediaStore.Video.Media.TITLE;
Cursor videocursor = managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
proj, null, null, orderBy);
要获得尺寸,您可以使用
int count = videocursor.getCount();