Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query all albums to a given artist

I need a way to display all albums of a given artist. All I found so far ist a way to list all albums which contain at least one songe of the artist - but that's not, what I want. I'm new to android an help would be very appreciated. Thank's in advance!

like image 785
sprestel Avatar asked Nov 26 '25 11:11

sprestel


1 Answers

It may be far to late but it may be interesting to someone else:

I had the same problem and only found obscure solutions how to query all albums done by a specific artist, then I came up with this rather simple solution:

Uri.Builder builder = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI.buildUpon();
builder.appendPath(artistId);
builder.appendPath("albums");

cursor = parent.managedQuery(builder.build(), projection, null,
    null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER);

Edit: The above solution to get the Uri may be not the nicest, this should also work:

Uri uri = MediaStore.Audio.Artists.Albums.getContentUri("external", artistId);

The artistId is the value of the MediaStore.Audio.Artists._ID from a previous Artist query.

like image 156
Luminger Avatar answered Nov 28 '25 02:11

Luminger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!