我得到了流派:
public static CursorLoader getGenres(Context context) {
Uri uri = MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI;
String[] columns = { MediaStore.Audio.Genres._ID,
MediaStore.Audio.Genres.NAME };
String orderBy = MediaStore.Audio.Genres.NAME;
return new CursorLoader(context, uri, columns, null, null, orderBy);
}
但我需要每种类型的歌曲数量。我可以为每种类型执行此操作:
private int getNumberSongsOfGenre(long genreID) {
Uri uri = MediaStore.Audio.Genres.Members.getContentUri(VOLUMENAME,
genreID);
Cursor c = resolver.query(uri, null, null, null, null);
if (c == null || c.getCount() == 0)
return -1;
int num = c.getCount();
c.close();
return num;
}
...但我需要在同一个查询中执行此操作并返回一个 CursorLoader。任何想法?