0

以下是我从 android 设备中获取所有歌曲的代码:

String[] proj = { MediaStore.Audio.Media._ID,
                MediaStore.Audio.Media.DATA,
                MediaStore.Audio.Media.DISPLAY_NAME,
                MediaStore.Audio.Media.SIZE };
        musiccursor = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,proj, null, null, null);

music_column_index=musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME);
music_column_index = musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE);

上面给了我设备中任何文件夹中所有歌曲的列表,但是我不想从特定文件夹(比如music_folder)中获取歌曲。有人可以帮助修改查询吗?

4

1 回答 1

2

尝试这个:

String[] proj = { MediaStore.Audio.Media._ID,
                MediaStore.Audio.Media.DATA,
                MediaStore.Audio.Media.DISPLAY_NAME,
                MediaStore.Audio.Media.SIZE };
String selection = MediaStore.Audio.Media.DATA +" NOT LIKE '%/music_folder/%'";
        musiccursor = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,proj, selection, null, null);

music_column_index=musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME);
music_column_index = musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE);
于 2013-04-20T09:38:02.920 回答