Context
I'm learning Android app development and to learn I thought I would build a music library app. I intend for the app initially to show songs from other apps on the device (then eventually moving onto playback). For example, on my phone there is music in both One Drive and Play Music. I would like to query both of their libraries.
What I've Tried
I uploaded a couple of songs (.mp3 & .flac) into the the sdcard/Music
folder on the device. I ensured Play Music and Groove had populated music libraries.
public SongReader GetSongs()
{
Cursor cursor = activity
.getContentResolver()
.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Audio.AudioColumns.DISPLAY_NAME + " ASC");
return new SongReader(cursor);
}
SongReader
is a custom class designed to iterate over a Cursor
and read custom Song
objects.
Problem
No songs are returned from the query call. Using the debugger and evaluating cursor.getCount()
returns 0
and cursor.getColumns()
returns 27 values.
Question
How can the music libraries of other apps be queried?
(Optional) Why did the couple of songs I uploaded to the device not get returned in the query response?
(Optional) Is there any way, I can detect any app installed on the device that "exposes" a media library?