从mediaStore中选择多个文件夹

时间:2018-02-01 16:56:24

标签: android mysql android-sqlite mediastore android-music-player

我尝试通过查询mediaStore来选择多个文件夹。我可以通过唱这段代码来选择一个文件夹:

 String[] whereVal;
    String selection;


Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;

 selection = MediaStore.Audio.Media.DATA + " like ? " ;
        whereVal = new String[]{"%Folder%"};


    String[] projection = {MediaStore.Audio.Media._ID,
            MediaStore.Audio.Media.TITLE,
            MediaStore.Audio.Media.ARTIST,
            MediaStore.Audio.Media.DURATION,
            MediaStore.Audio.Media.DATA,
            MediaStore.Audio.Media.ALBUM_ID};
    Cursor cursor = getActivity().getContentResolver().query(uri, projection, selection, whereVal, null);

但是,当我尝试选择多个文件夹时,mediaStore不会返回任何内容。 代码:

 Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;

        selection = MediaStore.Audio.Media.DATA + "  IN(?,?)" ;
        whereVal = new String[]{"%Top 20 English%","%Audio%"};

 String[] projection = {MediaStore.Audio.Media._ID,
            MediaStore.Audio.Media.TITLE,
            MediaStore.Audio.Media.ARTIST,
            MediaStore.Audio.Media.DURATION,
            MediaStore.Audio.Media.DATA,
            MediaStore.Audio.Media.ALBUM_ID};
    Cursor cursor = getActivity().getContentResolver().query(uri, projection, selection, whereVal, null);

小心帮帮我吗?预先感谢。 PS:我不想使用OR运算符。

0 个答案:

没有答案