Question

I am trying to get all albums that are by a particular artist by using the query method. However, i am a beginner and i don't know how to pass a selection argument in the query method.

This is what i have so far:

artistAlbumCursor = getContentResolver().query(
                MediaStore.Audio.Artists.Albums.ALBUM, null,
                MediaStore.Audio.Media.ARTIST=?, new String[] {artistChosen},
                MediaStore.Audio.Artists.Albums.ALBUM + " ASC");

Where artistChosen is the String containing the artist needed.

As I said i don't actually know how to pass a selection argument in so this was just an attempt.

So i guess what I'm asking is, how do i pass a selection argument into the query method.

Any help will be greatly appreciated.

Was it helpful?

Solution

try with this

artistAlbumCursor = getContentResolver().query(
                MediaStore.Audio.Artists.Albums.ALBUM, null,
                MediaStore.Audio.Media.ARTIST+ "=?", new String[] {artistChosen},
                MediaStore.Audio.Artists.Albums.ALBUM + " ASC");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top