我想在一个查询中从mediastore检索整个audio_genres_map表。我有所有音频信息和流派信息,但缺少的部分是映射。我可以在多个查询中执行此操作。我想实现一个查询
答案 0 :(得分:1)
设法使用以下查询解决此问题
String[] genresProjection = {
Audio.Genres.Members.AUDIO_ID,
Audio.Genres.Members.GENRE_ID
};
context.getContentResolver().query(Uri.parse("content://media/external/audio/genres/all/members"), genresProjection, null, null, null);
答案 1 :(得分:0)
或者使用MediaStore.Audio检索所有类型
public Cursor getGenrecursor(Context context) {
ContentResolver cr = context.getContentResolver();
Uri uri = MediaStore.Audio.Genres.getContentUri("external");
String genre = MediaStore.Audio.Genres.NAME;
final String[] columns = { "_id", genre };
return cr.query(uri, columns, null, null, null);
}
答案 2 :(得分:0)
并扩展您的问题,使用genre_id带回更多详细信息
public Cursor getgenre_TrackCursor(Context context, long genreID) {
final String track_id = MediaStore.Audio.Genres.Members._ID;
final String track_no = MediaStore.Audio.Genres.Members.TRACK;
final String track_name = MediaStore.Audio.Genres.Members.TITLE;
final String artist = MediaStore.Audio.Genres.Members.ARTIST;
final String duration = MediaStore.Audio.Genres.Members.DURATION;
final String album = MediaStore.Audio.Genres.Members.ALBUM;
final String composer = MediaStore.Audio.Genres.Members.COMPOSER;
final String year = MediaStore.Audio.Genres.Members.YEAR;
final String path = MediaStore.Audio.Genres.Members.DATA;
final ContentResolver resolve = context.getContentResolver();
Uri uri = MediaStore.Audio.Genres.Members.getContentUri("external",
genreID);
final String[] columns = { track_id, track_no, artist, track_name,
album, duration, year };
return resolve.query(uri, columns, null, null, null);
}