added in version 26.1.0
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1

MimeTypeFilter

public final class MimeTypeFilter
extends Object

java.lang.Object
   ↳ android.support.v4.content.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(String) 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 methods

static String matches(String[] mimeTypes, String filter)

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

static boolean matches(String mimeType, String filter)

Matches one nullable MIME type against one MIME type filter.

static String matches(String mimeType, String[] filters)

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

static String[] matchesMany(String[] mimeTypes, String filter)

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

Inherited methods

From class java.lang.Object

Public methods

matches

added in version 26.1.0
String matches (String[] mimeTypes, 
                String filter)

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

Parameters
mimeTypes String

filter String

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

matches

added in version 26.1.0
boolean matches (String mimeType, 
                String filter)

Matches one nullable MIME type against one MIME type filter.

Parameters
mimeType String

filter String

Returns
boolean True if the mimeType matches the filter.

matches

added in version 26.1.0
String matches (String mimeType, 
                String[] filters)

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

Parameters
mimeType String

filters String

Returns
String The first matching filter, or null if nothing matches.

matchesMany

added in version 26.1.0
String[] matchesMany (String[] mimeTypes, 
                String filter)

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

Parameters
mimeTypes String

filter String

Returns
String[] The list of matching MIME types, or empty array if nothing matches.