Question

I am trying to synchronize my own database for tracks and albums (that contains additional data). I have so far successfully pulled albums and tracks from the MediaStore.

What I cannot manage to do properly is to pull the Genres for the tracks. Could someone post some code? I'd like to avoid querying the database for each track, so if possible some code to load the association (Genre.id <-> Audio.id) would be great.

What I am struggling on is using the content provider to get the Genres.Members info.

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top