MimeTypeFilter

Added in 1.1.0

class MimeTypeFilter


Provides utility methods for matching MIME type filters used in ContentProvider.

Wildcards are allowed only instead of the entire type or subtype with a tree prefix. Eg. image\/*, *\/* is a valid filter and will match image/jpeg, but image/j* is invalid and it will not match image/jpeg. Suffixes and parameters are not supported, and they are treated as part of the subtype during matching. Neither type nor subtype can be empty.

Note: MIME type matching in the Android framework is case-sensitive, unlike the formal RFC definitions. As a result, you should always write these elements with lower case letters, or use normalizeMimeType to ensure that they are converted to lower case.

MIME types can be null or ill-formatted. In such case they won't match anything.

MIME type filters must be correctly formatted, or an exception will be thrown.

Summary

Public functions

java-static Boolean
matches(mimeType: String?, filter: String)

Matches one nullable MIME type against one MIME type filter.

java-static String?
matches(mimeType: String?, filters: Array<String!>)

Matches one nullable MIME type against an array of MIME type filters.

java-static String?
matches(mimeTypes: Array<String!>?, filter: String)

Matches multiple MIME types against an array of MIME type filters.

java-static Array<String!>
matchesMany(mimeTypes: Array<String!>?, filter: String)

Matches multiple MIME types against an array of MIME type filters.

Public functions

matches

Added in 1.1.0
java-static fun matches(mimeType: String?, filter: String): Boolean

Matches one nullable MIME type against one MIME type filter.

Returns
Boolean

True if the mimeType matches the filter.

matches

Added in 1.1.0
java-static fun matches(mimeType: String?, filters: Array<String!>): String?

Matches one nullable MIME type against an array of MIME type filters.

Returns
String?

The first matching filter, or null if nothing matches.

matches

Added in 1.1.0
java-static fun matches(mimeTypes: Array<String!>?, filter: String): String?

Matches multiple MIME types against an array of MIME type filters.

Returns
String?

The first matching MIME type, or null if nothing matches.

matchesMany

Added in 1.1.0
java-static fun matchesMany(mimeTypes: Array<String!>?, filter: String): Array<String!>

Matches multiple MIME types against an array of MIME type filters.

Returns
Array<String!>

The list of matching MIME types, or empty array if nothing matches.