List all music files

4 votes · 1 comment

Retrieve a list of Music files currently listed in the Media store DB via URI.

raw ·
copy
· download
//Some audio may be explicitly marked as not being music String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0"; String[] projection = { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.DISPLAY_NAME, MediaStore.Audio.Media.DURATION }; cursor = this.managedQuery( MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null, null); private List<String> songs = new ArrayList<String>(); while(cursor.moveToNext()){ songs.add(cursor.getString(0) + "||" + cursor.getString(1) + "||" + cursor.getString(2) + "||" + cursor.getString(3) + "||" + cursor.getString(4) + "||" + cursor.getString(5)); }
Add a comment

1 Comment

is it really work?

Reply · Oct. 24, 2013, 4:36 a.m.