Example usage for android.webkit MimeTypeMap getSingleton

List of usage examples for android.webkit MimeTypeMap getSingleton

Introduction

In this page you can find the example usage for android.webkit MimeTypeMap getSingleton.

Prototype

public static MimeTypeMap getSingleton() 

Source Link

Document

Get the singleton instance of MimeTypeMap.

Usage

From source file:com.android.mms.ui.MessageUtils.java

public static String getContentType(Uri uri) {
    String path = uri.getPath();/*from   w  ww .j  a v a  2 s . c  om*/

    MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
    String extension = MimeTypeMap.getFileExtensionFromUrl(path).toLowerCase();
    if (TextUtils.isEmpty(extension)) {
        int dotPos = path.lastIndexOf('.');
        if (0 <= dotPos) {
            extension = path.substring(dotPos + 1);
            extension = extension.toLowerCase();
        }
    }

    String type = mimeTypeMap.getMimeTypeFromExtension(extension);
    return type;
}