Java tutorial
//package com.java2s; import android.webkit.MimeTypeMap; import java.io.File; public class Main { public static String getMimeType(File file) { return getMimeType(file.getAbsolutePath()); } 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; } }