私はジャンルを取得します:
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を返す必要があります。何か案が?