用下面代码对SD卡中的音乐进行获取: ContentResolver resolver = getContentResolver();
cursor = resolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
null, null, null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
但是返回的Cursor为空。于是我对SD卡进行扫描:Intent intent = new Intent(
"android.intent.action.MEDIA_SCANNER_SCAN_DIR");
File file = Environment.getExternalStorageDirectory();
intent.setData(Uri.fromFile(file));
sendBroadcast(intent);但是Cursor还是为空,为什么?
cursor = resolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
null, null, null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
但是返回的Cursor为空。于是我对SD卡进行扫描:Intent intent = new Intent(
"android.intent.action.MEDIA_SCANNER_SCAN_DIR");
File file = Environment.getExternalStorageDirectory();
intent.setData(Uri.fromFile(file));
sendBroadcast(intent);但是Cursor还是为空,为什么?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货