Fork me on GitHub

Get Metadata of Audio files using Cursor in Android

Posted on 15 August 2014
Under Blog
Tagged
Android
Get Metadata of Audio files using Cursor in Android | Jay Rambhia’s Blog

We are building a music app and as you would have guessed we would require all the audio metadata. At first, we tried using Android’s Intent but it would let us select only one audio file at a time. Also, there was a setback if the user had disabled the default music player and other player did not listen to this intent. So we tried to look up for other ways to obtain metadata of all the audio files. We first used MediaMetaDataRetriever but it would give null String for some of the audio objects.

After a bit of searching, we found an easy method which would give us all of the required metadata and that too very quickly. We used Android’s ContentResolver to query external audio files of the device.

Query using ContentResolver


Extracting Metadata from Cursor

After getting the cursor, we would extract the metadata and create new instances of QueryObject (our class to handle audio queries) for each entry.


To show all these audio files, we were using custom ArrayAdapter and ListView.

P.S. The app is turning out to be really cool.

comments powered by Disqus


If you have some feedback or questions regarding this post, please add comments. I'd be happy to get some feedback.



If you liked this post, then you should follow Jay on twitter too. He would be excited to know that you like his work.