I have been researching this for hours now. I've looked at android javadoc - MediaStore and I just don't get it. I've looked for examples. Nothing.
I want to search the music library for a string. I have the main idea in my mind (get music library DB, search it like you would a sqlite DB) but I literally have no idea how to do it.
I have also found the URI for external SD media files - MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
but I don't really know what to do with this.
Some starting points would be nice..
Thank you.
From the Home screen, tap Apps > Music Player . The Music Player application searches your phone for music files you copied into it, then builds a catalog of your music based on the information contained in each music file.
The MediaStore
more or less is an sqlite DB. There are many ways to query it. By album, by artist, by playlist, by song, and so on. This will return a Cursor
of all songs, for example.
Cursor cursor = getContentResolver().query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
null,
null,
null,
MediaStore.Audio.Media.TITLE + " ASC");
You can then get specific columns from it like so:
while (cursor.moveToNext()) {
String title = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.TITLE));
// Whatever else you need
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With