java MediaStore外部内容URI正在从SD卡获取数据
我正在使用MediaStore和Cursor从指定文件夹获取音频文件。我想要的是,它应该从手机的内部存储器获取歌曲列表,但它是从SD卡获取的。虽然我尝试过使用内部内容,但它什么也得不到。请看一下,有什么问题吗。任何帮助都将不胜感激
String AudioFilePath = "%" +"/nexcox/voicerecorder/audio/" +"%";
Uri uri= MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
String selection= MediaStore.Audio.Media.DATA +" LIKE ? ";
Cursor cursor=context.getContentResolver().query(uri,null,selection,
new String[]{AudioFilePath},
null);
if (cursor!=null){
if (cursor.moveToFirst()){
do {
String name = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
String duration = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DURATION));
String sourceLocation = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DATA));
AudioInfo audioInfo=new AudioInfo(name,duration,sourceLocation);
audioInfos.add(audioInfo);
}while (cursor.moveToNext());
}
cursor.close();
audioAdapter=new AudioAdapter(context,audioInfos);
recyclerView.setAdapter(audioAdapter);
}
# 1 楼答案
比如
在代码中:
# 2 楼答案
我使用与你的例子相同的方法。很好