Querying MediaStore as you search via an EditText

两盒软妹~` 提交于 2019-12-08 10:28:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!