Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to exclude ringtones and notifications from songs

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?

like image 833
Dileep Perla Avatar asked Jan 21 '26 00:01

Dileep Perla


1 Answers

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);
like image 137
Brian Cooley Avatar answered Jan 23 '26 13:01

Brian Cooley