Take the 2-minute tour ×

I have a extension-less file, named for the sake of this post MyAudioFile, I know that this audio file's extension is aac format(I have analysed it with a program named GSpot), but since the file doesn't have any extension, I am unable to use any of the methods available in Android for determining MIME type of that file.

Is there any inbuilt utility method in Android that I am unaware of and which lets me read the header information of an audio file and spit out the extension or the MIME type of the file?

I have already tried MediaMetaDataRetriever and MimeTypeMap unsuccessfully, did I miss any other class which can be used here?

Is it possible using any other external libraries excluding SOX and FFMPeg?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

I'm not sure I understand what the problem is here. MediaMetaDataRetriever is the class to use to determine the metadata (including MIME type) of an arbitrary media file. Are you perhaps using it wrong?

MediaMetaDataRetriever retriever = new MediaMetaDataRetriever();
String mimeType = retriever.extractMetadata(MediaMetaDataRetriever.METADATA_KEY_MIMETYPE);

How exactly are you trying to use this file? You shouldn't need its MIME type to use it (and you admittedly already know its MIME type - audio/mp4)

share|improve this answer
I used the above it returns null, you see I have some special cases where there are audio files with supposedly no extensions, my goal is to find out the extension of such files programatically and append it to the filename. –  Arif Nadeem Feb 15 '13 at 21:08
add comment

Why can't you just add the extension manually?

share|improve this answer
How do I know the extension beforehand? As I said I analysed the audio file in the above scenario but there are many other audio files, I want to know the mime type of the programatically. –  Arif Nadeem Feb 15 '13 at 20:44
Ok, i didn't knew that there were many other files. If I have understood you correctly you want to add the extension to a lot of files. Now i don't know GSpot but you use a macro or something like that to automate the process and left the computer over the night? –  DSDeniso Feb 15 '13 at 22:31
add comment

Your Answer


