1

我有一个 ArrayList 包含文件夹名称,其中包含歌曲:

private ArrayList<String> searchableDir = new ArrayList<String>();
searchableDir.add("/mnt/sdcard/Tracks/U2/");
searchableDir.add("/mnt/sdcard/Tracks/Coldplay/");

现在我想运行一个托管查询,该查询将从这两个文件夹中获取歌曲。目前我一次只能获取一个文件夹:

String abc = "/mnt/sdcard/Tracks/U2/";
cursor = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
            projection, MediaStore.Audio.Media.DATA + " LIKE \""
            + abc + "%\"", null, MediaStore.Audio.Media.TITLE
            + " ASC");

以上查询的工作方式如下:

select _id from audio where _data like "/mnt/sdcard/Tracks/U2/%";

但我想制作一个托管查询,它将从 searchableDir 数组列表中的所有文件夹中获取曲目。请建议。

提前致谢。

4

1 回答 1

0

使用以下获取 sdcard 中可用的所有音频文件:

字符串[] 星 = { "*" };
Uri allaudiosong = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
字符串音频选择 = MediaStore.Audio.Media.IS_MUSIC + "!= 0";
光标 cursor = mContext.managedQuery(allaudiosong, STAR, audioselection, null, null);

于 2012-11-20T08:56:30.570 回答