如何读取外部音乐
发布网友
发布时间:2023-01-20 18:48
我来回答
共1个回答
热心网友
时间:2024-11-23 14:56
ContentResolver mResolver = getContentResolver();
Cursor cursor = mResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
int i = 0;
int cursorCount = cursor.getCount();
if (cursorCount >0 )
{
cursor.moveToFirst();
while (i < cursorCount)
{
//歌曲文件的路径 :MediaStore.Audio.Media.DATA
url = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));
if(url.toLowerCase().indexOf("指定的歌曲路径") > 0)
{
}
i++;
cursor.moveToNext();
}
cursor.close();
}