Jack
Jack

Reputation: 2053

Querying multiple specified file types with MediaStore

How can I query multiple specified file types when querying the MediaStore?

I have successfully set up querying only mp3 files with a specifed meme type but I would like to know how I can do more than 1.

Here's what I am doing to query only 1 file type:

     String selectionMimeType = MediaStore.Files.FileColumns.MIME_TYPE
            + "=?";

      String[] selectionArgsPdf = new String[] { MimeTypeMap.getSingleton()
            .getMimeTypeFromExtension("mp3"), };


        CursorLoader(getActivity(),
                MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                SONG_SUMMARY_PROJECTION, selectionMimeType,
                selectionArgsPdf, MediaStore.Audio.Media.DISPLAY_NAME);

How can I query only mp3 and another file type? thanks.

Upvotes: 0

Views: 244

Answers (1)

Abul
Abul

Reputation: 11

The following edit will do the job

Audio.Media.DATA + " like ? OR " + Audio.Media.DATA + " like ? ";
String[] selectionArgsPdf = new String[]{ "%mp3","%wav" };
CursorLoader(getActivity(), MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
            SONG_SUMMARY_PROJECTION, selectionMimeType,
            selectionArgsPdf, MediaStore.Audio.Media.DISPLAY_NAME);

Upvotes: 1

Related Questions