Searching for music files with mediastore
android
Solution
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
}
Problem
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.