Fetch Genre name list which have songs in it

主宰稳场 提交于 2019-12-03 15:41:29

It seems like there is no other method to achieve this so i have just do like below... With below update i can able to get the Genre list which only have songs in it. The genre list which don't have songs are filtered out.

public Loader<Cursor> onCreateLoader(int id, Bundle args) {

        Uri baseUri;
        if (mCurFilter != null) {
            baseUri = Uri.withAppendedPath(
                    MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                    Uri.encode(mCurFilter));
        } else {
            baseUri = MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI;
        }

        String[] STAR = { MediaStore.Audio.Genres._ID,
                MediaStore.Audio.Genres.NAME };


        String query = " _id in (select genre_id from audio_genres_map where audio_id in (select _id from audio_meta where is_music != 0))" ;

        return new CursorLoader(getActivity(),
                MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI, STAR, query,
                null, null);

    }

In above code i have join the genre table with audio table. with this way i am able to fetch, whether that Genre have songs or not. So now i have only that genre which have songs in it.

Hope this will help others also.

Enjoy Coding... :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!