Android examples for android.webkit:MimeTypeMap
get Extension For Mime Type
import android.text.TextUtils; import android.webkit.MimeTypeMap; public class Main { public static String getExtensionForMimeType(String mimeType) { if (TextUtils.isEmpty(mimeType)) return ""; MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton(); String fileExtensionFromMimeType = mimeTypeMap.getExtensionFromMimeType(mimeType); if (TextUtils.isEmpty(fileExtensionFromMimeType)) { // We're still without an extension - split the mime type and retrieve it String[] split = mimeType.split("/"); fileExtensionFromMimeType = split.length > 1 ? split[1] : split[0]; }/*from www. ja v a2s . c o m*/ return fileExtensionFromMimeType.toLowerCase(); } }