用ContentResolver取不到MediaStore里的内容
ContentResolver cr =this.getContentResolver();
Cursor tempCur = cr.query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
/*new String[]{ 毕业论文
MediaStore.Audio.Media._ID, //int
MediaStore.Audio.Media.DATA, //String
MediaStore.Audio.Media.DISPLAY_NAME, //String
MediaStore.Audio.Media.MIME_TYPE //String
}*/
null,//无论取null还是上边的数组都是一样的
null, null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER); //order取null也是一样的
if(tempCur!=null){
if(D)Log.d(TAG,"Cursor.getCount in Audio"+tempCur.getCount());
}else{
if(D)Log.d(TAG,"Cursor.getCount in Audio is NULL");
}
manifest 权限 :
XML/HTML code?12 <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
在我自己的手机上调试 moto defy+ (因为虚拟机里木有多媒体文件...懒得弄...)
手机里有一堆歌...
catlog:
06-27 23:29:38.139: D/Puzzle_Config(16872): Cursor.getCount in Audio is NULL
是不是URI不对呢?
截取log不全~ 打印cr和tempCur是否为null
例如
MediaStore.Audio.Media.DATA= “data”
MediaStore.Audio.Media.DISPLAY_NAME=“displayName”
MediaStore.Audio.Media.MIME_TYPE=“mimeType”
/*new String[]{
MediaStore.Audio.Media._ID, //int
MediaStore.Audio.Media.DATA, //String
MediaStore.Audio.Media.DISPLAY_NAME, //String
MediaStore.Audio.Media.MIME_TYPE //String
}*/
修改成new String[]{
"_id","data,"displayName","mimeType"
}