Q:

Is there any android API to get the file type using file format

I am working on an android application and need to filter files using their file format. What I exactly want to do is this:
input: "jpg" => output: "image"
input: "mp3" => output: "audio"
input: "mov" => output: "video"
Is there any android API to do this or I have to manually store this information in my app.

A:

You can use the MimeTypeMap class which will return some thing like this 'text/plain'.
You can also read up on mime types here
// the File name or Url
public static String getMimeType(String url)
{
    String type = null;
    String extension = MimeTypeMap.getFileExtensionFromUrl(url);
    if (extension != null) {
        MimeTypeMap mime = MimeTypeMap.getSingleton();
        type = mime.getMimeTypeFromExtension(extension);
    }
    return type;
}

