Android: How to exclude ringtones and notifications from songs

android, mediastore

Solution

Add a selection to your managed query call.

String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";
Cursor mediacur = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, selection, null, null);

Problem

I am developing a music player application and querying for the album names through the following code : ``` Cursor mediacur = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, null); mediacur.moveToFirst(); do{ albumindex = mediacur.getColumnIndex(MediaStore.Audio.Media.ALBUM); albumname = mediacur.getString(albumindex); songs.add(albumname); }while(mediacur.moveToNext()); ``` I am getting all the album names along with Ringtones and Notifications too. How can I exclude the ringtones and notifications from my list?

Original source