Getting efficiently the Genres of the Audio files in the MediaStore

▼魔方 西西 提交于 2019-12-01 00:25:28

I'd take a look at how the excellent creators of ringdroid do this. http://ringdroid.googlecode.com/svn-history/r37/trunk/src/com/ringdroid/SongMetadataReader.java

They basically start by retrieving the genres names and ids and using those they can easily create a content_uri that retrieves only songs in the database that matches those genres. But if I were you I would check whether there is an "unknown" or "empty" genre or not for the files that contain no Genre name in their id3 tag

So what I ended up doing is getting all audio files on the sd with a loader and following query:

        loader = new CursorLoader(mActivity, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, 
                new String[] {Audio.Media._ID, Audio.Media.DATA}, 
                null, null, null);

Then i check if they end with .mp3 and I then use jaudiotagger and read the ide3 tags for genre.

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