查询MediaStore你通过搜索的EditTextMediaStore、EditText

2023-09-07 00:11:03 作者:青春为你更新

我试图找出我怎么能查询MediaStore特定字符,我通过我的EditText搜索。

I am trying to figure out how I can query the MediaStore for specific characters as I search via my EditText.

我对搜索MediaStore 目前的解决方案就来自这里。

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.

我想知道如何使它所以,当我渐渐输入歌曲名称,它发现有名字相同的字符,我进入我的EditText的歌曲。

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.

下面是我的code:

Cursor cursor = getContentResolver().query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, 
null, 
MediaStore.Audio.Media.TITLE + "=?", 
new String[]{songToPlay}, 
MediaStore.Audio.Media.TITLE + " ASC");

感谢您的时间提前。

推荐答案

替换

MediaStore.Audio.Media.TITLE + "=?",
new String[]{songToPlay}, 

MediaStore.Audio.Media.TITLE + " LIKE ?",
new String[]{"%" + songToPlay + "%"},