问题
I am trying to figure out how I can query the MediaStore for specific characters as I search via my EditText.
My current solution for searching the MediaStore came from here.
And as Ken states, you have to input the name of the song exactly for anything to come up.
I would like to know how to make it so that when I gradually input a song name, it finds the songs that have the same characters in the name that I am entering into my EditText.
Here's my code:
Cursor cursor = getContentResolver().query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
null,
MediaStore.Audio.Media.TITLE + "=?",
new String[]{songToPlay},
MediaStore.Audio.Media.TITLE + " ASC");
Thank you for your time in advance.
回答1:
Replace
MediaStore.Audio.Media.TITLE + "=?",
new String[]{songToPlay},
with
MediaStore.Audio.Media.TITLE + " LIKE ?",
new String[]{"%" + songToPlay + "%"},
来源:https://stackoverflow.com/questions/31843094/querying-mediastore-as-you-search-via-an-edittext