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.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# MimeTypeFilter\n\nadded in [version 26.1.0](/topic/libraries/support-library/revisions) \nbelongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1 \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \\| [\\[Expand All\\]](#) \n\nMimeTypeFilter\n==============\n\n| This package is part of the Android [support library](/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](/jetpack/androidx) which is part of [Jetpack](/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class\n| mappings](/jetpack/androidx/migrate/class-mappings).\n\n\n`\npublic\n\nfinal\n\nclass\nMimeTypeFilter\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\n`\n\n|---|-------------------------------------------|\n| java.lang.Object ||\n| ↳ | android.support.v4.content.MimeTypeFilter |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nProvides utility methods for matching MIME type filters used in ContentProvider.\n\nWildcards are allowed only instead of the entire type or subtype with a tree prefix.\nEg. image\\\\/\\*, \\*\\\\/\\* is a valid filter and will match image/jpeg, but image/j\\* is invalid and\nit will not match image/jpeg. Suffixes and parameters are not supported, and they are treated\nas part of the subtype during matching. Neither type nor subtype can be empty.\n\n*Note: MIME type matching in the Android framework is case-sensitive, unlike the formal\nRFC definitions. As a result, you should always write these elements with lower case letters,\nor use [normalizeMimeType(String)](https://developer.android.com/reference/android/content/Intent.html#normalizeMimeType(java.lang.String)) to ensure that they are converted to\nlower case.*\n\nMIME types can be null or ill-formatted. In such case they won't match anything.\n\nMIME type filters must be correctly formatted, or an exception will be thrown.\n\nSummary\n-------\n\n| ### Public methods ||\n|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` static String` | ` `[matches](/reference/android/support/v4/content/MimeTypeFilter#matches(java.lang.String[], java.lang.String))`(String[] mimeTypes, String filter) ` Matches multiple MIME types against an array of MIME type filters. |\n| ` static boolean` | ` `[matches](/reference/android/support/v4/content/MimeTypeFilter#matches(java.lang.String, java.lang.String))`(String mimeType, String filter) ` Matches one nullable MIME type against one MIME type filter. |\n| ` static String` | ` `[matches](/reference/android/support/v4/content/MimeTypeFilter#matches(java.lang.String, java.lang.String[]))`(String mimeType, String[] filters) ` Matches one nullable MIME type against an array of MIME type filters. |\n| ` static String[]` | ` `[matchesMany](/reference/android/support/v4/content/MimeTypeFilter#matchesMany(java.lang.String[], java.lang.String))`(String[] mimeTypes, String filter) ` Matches multiple MIME types against an array of MIME type filters. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` java.lang.Object ` |-------------------|-------------------------------| | ` Object` | ` clone() ` | | ` boolean` | ` equals(Object arg0) ` | | ` void` | ` finalize() ` | | ` final Class\u003c?\u003e` | ` getClass() ` | | ` int` | ` hashCode() ` | | ` final void` | ` notify() ` | | ` final void` | ` notifyAll() ` | | ` String` | ` toString() ` | | ` final void` | ` wait(long arg0, int arg1) ` | | ` final void` | ` wait(long arg0) ` | | ` final void` | ` wait() ` | ||\n\nPublic methods\n--------------\n\n### matches\n\nadded in [version 26.1.0](/topic/libraries/support-library/revisions) \n\n```\nString matches (String[] mimeTypes, \n String filter)\n```\n\nMatches multiple MIME types against an array of MIME type filters.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------------|-----------------|\n| `mimeTypes` | `String` \u003cbr /\u003e |\n| `filter` | `String` \u003cbr /\u003e |\n\n| Returns ||\n|----------|------------------------------------------------------------------|\n| `String` | The first matching MIME type, or null if nothing matches. \u003cbr /\u003e |\n\n### matches\n\nadded in [version 26.1.0](/topic/libraries/support-library/revisions) \n\n```\nboolean matches (String mimeType, \n String filter)\n```\n\nMatches one nullable MIME type against one MIME type filter.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|-----------------|\n| `mimeType` | `String` \u003cbr /\u003e |\n| `filter` | `String` \u003cbr /\u003e |\n\n| Returns ||\n|-----------|-----------------------------------------------------|\n| `boolean` | True if the `mimeType` matches the `filter`. \u003cbr /\u003e |\n\n### matches\n\nadded in [version 26.1.0](/topic/libraries/support-library/revisions) \n\n```\nString matches (String mimeType, \n String[] filters)\n```\n\nMatches one nullable MIME type against an array of MIME type filters.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|-----------------|\n| `mimeType` | `String` \u003cbr /\u003e |\n| `filters` | `String` \u003cbr /\u003e |\n\n| Returns ||\n|----------|---------------------------------------------------------------|\n| `String` | The first matching filter, or null if nothing matches. \u003cbr /\u003e |\n\n### matchesMany\n\nadded in [version 26.1.0](/topic/libraries/support-library/revisions) \n\n```\nString[] matchesMany (String[] mimeTypes, \n String filter)\n```\n\nMatches multiple MIME types against an array of MIME type filters.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------------|-----------------|\n| `mimeTypes` | `String` \u003cbr /\u003e |\n| `filter` | `String` \u003cbr /\u003e |\n\n| Returns ||\n|------------|----------------------------------------------------------------------------|\n| `String[]` | The list of matching MIME types, or empty array if nothing matches. \u003cbr /\u003e |\n\n-\n\n Interfaces\n ----------\n\n - [Loader.OnLoadCanceledListener](/reference/android/support/v4/content/Loader.OnLoadCanceledListener)\n - [Loader.OnLoadCompleteListener](/reference/android/support/v4/content/Loader.OnLoadCompleteListener)\n-\n\n Classes\n -------\n\n - [AsyncTaskLoader](/reference/android/support/v4/content/AsyncTaskLoader)\n - [ContentResolverCompat](/reference/android/support/v4/content/ContentResolverCompat)\n - [ContextCompat](/reference/android/support/v4/content/ContextCompat)\n - [CursorLoader](/reference/android/support/v4/content/CursorLoader)\n - [FileProvider](/reference/android/support/v4/content/FileProvider)\n - [IntentCompat](/reference/android/support/v4/content/IntentCompat)\n - [Loader](/reference/android/support/v4/content/Loader)\n - [Loader.ForceLoadContentObserver](/reference/android/support/v4/content/Loader.ForceLoadContentObserver)\n - [LocalBroadcastManager](/reference/android/support/v4/content/LocalBroadcastManager)\n - [MimeTypeFilter](/reference/android/support/v4/content/MimeTypeFilter)\n - [PermissionChecker](/reference/android/support/v4/content/PermissionChecker)\n - [SharedPreferencesCompat](/reference/android/support/v4/content/SharedPreferencesCompat)\n - [SharedPreferencesCompat.EditorCompat](/reference/android/support/v4/content/SharedPreferencesCompat.EditorCompat)\n - [WakefulBroadcastReceiver](/reference/android/support/v4/content/WakefulBroadcastReceiver)"]]