Inserting Audio into the MediaStore

Audio recordings may be put into the MediaStore content provider so they are available to other applications. The process is very similar to the process we used earlier to add images to the MediaStore. In this case though, we'll add them after they are created.

We create a ContentValues object to hold the data that we'll insert into the MediaStore. A ContentValues object is made up of a series of key/value pairs. The keys that may be used are defined as constants in the MediaStore.Audio.Media class (and those classes it inherits from).

The MediaStore.Audio.Media.DATA constant is the key for the path to the recorded file. It is the only required pair in order to insert the file into the MediaStore.

To do the ...

Get Pro Android Media: Developing Graphics, Music, Video, and Rich Media Apps for Smartphones and Tablets now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.