Share via


ContentProvider.GetType(Uri) Method

Definition

Implement this to handle requests for the MIME type of the data at the given URI.

[Android.Runtime.Register("getType", "(Landroid/net/Uri;)Ljava/lang/String;", "GetGetType_Landroid_net_Uri_Handler")]
public abstract string? GetType (Android.Net.Uri uri);
[<Android.Runtime.Register("getType", "(Landroid/net/Uri;)Ljava/lang/String;", "GetGetType_Landroid_net_Uri_Handler")>]
override this.GetType : Android.Net.Uri -> string

Parameters

uri
Uri

the URI to query.

Returns

a MIME type string, or null if there is no type.

Attributes

Remarks

Implement this to handle requests for the MIME type of the data at the given URI. The returned MIME type should start with vnd.android.cursor.item for a single record, or vnd.android.cursor.dir/ for multiple items. This method can be called from multiple threads, as described in Processes and Threads.

Note that by default there are no permissions needed for an application to access this information; if your content provider requires read and/or write permissions, or is not exported, all applications can still call this method regardless of their access permissions.

If your mime type reveals details that should be protected, then you should protect this method by implementing #getTypeAnonymous. Implementing #getTypeAnonymous ensures your #getType can be only accessed by caller's having associated readPermission for the URI.

Java documentation for android.content.ContentProvider.getType(android.net.Uri).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to