Skip to content Skip to sidebar Skip to footer

Filter A Managedquery By File Extension (or, Alternatively, File Type) For An Android Cursor

I want to do a managedQuery using Android SDK where the results returned are filtered by their respective file extension (e.g. not the name, necessarily). I've done quite a bit of

Solution 1:

I think all you have to do is change %mp3% to %mp3. This will force "mp3" to be at the end of the filename.

If you need to select multiple file types, do it like this:

managedQuery(
  Audio.Media.EXTERNAL_CONTENT_URI,
  myProjection, 
  Audio.Media.DATA + " like ? OR " + Audio.Media.DATA + " like ? ", 
  newString[] {"%mp3","%wav"}, 
  MediaStore.Audio.Media.TITLE + " ASC" );

Post a Comment for "Filter A Managedquery By File Extension (or, Alternatively, File Type) For An Android Cursor"