Added in API level 1

MimeTypeMap


open class MimeTypeMap
kotlin.Any
   ↳ android.webkit.MimeTypeMap

Two-way map that maps MIME-types to file extensions and vice versa.

See also java.net.URLConnection#guessContentTypeFromName and java.net.URLConnection#guessContentTypeFromStream. This class and URLConnection share the same MIME-type database.

Summary

Public methods
open String?

Return the registered extension for the given MIME type.

open static String!

Returns the file extension or an empty string if there is no extension.

open String?

Return the MIME type for the given extension.

open static MimeTypeMap!

Get the singleton instance of MimeTypeMap.

open Boolean
hasExtension(extension: String!)

Return true if the given extension has a registered MIME type.

open Boolean
hasMimeType(mimeType: String!)

Return true if the given MIME type has an entry in the map.

Public methods

getExtensionFromMimeType

Added in API level 1
open fun getExtensionFromMimeType(mimeType: String!): String?

Return the registered extension for the given MIME type. Note that some MIME types map to multiple extensions. This call will return the most common extension for the given MIME type.

Parameters
mimeType String!: A MIME type (i.e. text/plain)
Return
String? The extension for the given MIME type or null if there is none.

getFileExtensionFromUrl

Added in API level 1
open static fun getFileExtensionFromUrl(url: String!): String!

Returns the file extension or an empty string if there is no extension. This method is a convenience method for obtaining the extension of a url and has undefined results for other Strings.

Parameters
url String!:
Return
String! The file extension of the given url.

getMimeTypeFromExtension

Added in API level 1
open fun getMimeTypeFromExtension(extension: String!): String?

Return the MIME type for the given extension.

Parameters
extension String!: A file extension without the leading '.'
Return
String? The MIME type for the given extension or null if there is none.

getSingleton

Added in API level 1
open static fun getSingleton(): MimeTypeMap!

Get the singleton instance of MimeTypeMap.

Return
MimeTypeMap! The singleton instance of the MIME-type map.

hasExtension

Added in API level 1
open fun hasExtension(extension: String!): Boolean

Return true if the given extension has a registered MIME type.

Parameters
extension String!: A file extension without the leading '.'
Return
Boolean true if there is an extension entry in the map.

hasMimeType

Added in API level 1
open fun hasMimeType(mimeType: String!): Boolean

Return true if the given MIME type has an entry in the map.

Parameters
mimeType String!: A MIME type (i.e. text/plain)
Return
Boolean true if there is a mimeType entry in the map.