ContentProvider.OpenTypedAssetFile Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
OpenTypedAssetFile(Uri, String, Bundle) |
Called by a client to open a read-only stream containing data of a particular MIME type. |
OpenTypedAssetFile(Uri, String, Bundle, CancellationSignal) |
Called by a client to open a read-only stream containing data of a particular MIME type. |
OpenTypedAssetFile(Uri, String, Bundle)
Called by a client to open a read-only stream containing data of a particular MIME type.
[Android.Runtime.Register("openTypedAssetFile", "(Landroid/net/Uri;Ljava/lang/String;Landroid/os/Bundle;)Landroid/content/res/AssetFileDescriptor;", "GetOpenTypedAssetFile_Landroid_net_Uri_Ljava_lang_String_Landroid_os_Bundle_Handler")]
public virtual Android.Content.Res.AssetFileDescriptor? OpenTypedAssetFile (Android.Net.Uri uri, string mimeTypeFilter, Android.OS.Bundle? opts);
[<Android.Runtime.Register("openTypedAssetFile", "(Landroid/net/Uri;Ljava/lang/String;Landroid/os/Bundle;)Landroid/content/res/AssetFileDescriptor;", "GetOpenTypedAssetFile_Landroid_net_Uri_Ljava_lang_String_Landroid_os_Bundle_Handler")>]
abstract member OpenTypedAssetFile : Android.Net.Uri * string * Android.OS.Bundle -> Android.Content.Res.AssetFileDescriptor
override this.OpenTypedAssetFile : Android.Net.Uri * string * Android.OS.Bundle -> Android.Content.Res.AssetFileDescriptor
Parameters
- uri
- Uri
The data in the content provider being queried.
- mimeTypeFilter
- String
The type of data the client desires. May be a pattern, such as /, if the caller does not have specific type requirements; in this case the content provider will pick its best type matching the pattern.
- opts
- Bundle
Additional options from the client. The definitions of these are specific to the content provider being called.
Returns
Returns a new AssetFileDescriptor from which the client can read data of the desired type.
- Attributes
Exceptions
Throws FileNotFoundException if there is no file associated with the given URI or the mode is invalid.
Throws SecurityException if the caller does not have permission to access the data.
Throws IllegalArgumentException if the content provider does not support the requested MIME type.
Remarks
Called by a client to open a read-only stream containing data of a particular MIME type. This is like #openAssetFile(Uri, String)
, except the file can only be read-only and the content provider may perform data conversions to generate data of the desired type.
The default implementation compares the given mimeType against the result of #getType(Uri)
and, if they match, simply calls #openAssetFile(Uri, String)
.
See ClipData
for examples of the use and implementation of this method.
The returned AssetFileDescriptor can be a pipe or socket pair to enable streaming of data.
<p class="note">For better interoperability with other applications, it is recommended that for any URIs that can be opened, you also support queries on them containing at least the columns specified by android.provider.OpenableColumns
. You may also want to support other common columns if you have additional meta-data to supply, such as android.provider.MediaStore.MediaColumns#DATE_ADDED
in android.provider.MediaStore.MediaColumns
.
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.
See also
- <xref:Android.Content.ContentProvider.GetStreamTypes(Android.Net.Uri%2c+System.String)>
- <xref:Android.Content.ContentProvider.OpenAssetFile(Android.Net.Uri%2c+System.String)>
- <xref:Android.Content.ClipDescription.CompareMimeTypes(System.String%2c+System.String)>
Applies to
OpenTypedAssetFile(Uri, String, Bundle, CancellationSignal)
Called by a client to open a read-only stream containing data of a particular MIME type.
[Android.Runtime.Register("openTypedAssetFile", "(Landroid/net/Uri;Ljava/lang/String;Landroid/os/Bundle;Landroid/os/CancellationSignal;)Landroid/content/res/AssetFileDescriptor;", "GetOpenTypedAssetFile_Landroid_net_Uri_Ljava_lang_String_Landroid_os_Bundle_Landroid_os_CancellationSignal_Handler")]
public virtual Android.Content.Res.AssetFileDescriptor? OpenTypedAssetFile (Android.Net.Uri uri, string mimeTypeFilter, Android.OS.Bundle? opts, Android.OS.CancellationSignal? signal);
[<Android.Runtime.Register("openTypedAssetFile", "(Landroid/net/Uri;Ljava/lang/String;Landroid/os/Bundle;Landroid/os/CancellationSignal;)Landroid/content/res/AssetFileDescriptor;", "GetOpenTypedAssetFile_Landroid_net_Uri_Ljava_lang_String_Landroid_os_Bundle_Landroid_os_CancellationSignal_Handler")>]
abstract member OpenTypedAssetFile : Android.Net.Uri * string * Android.OS.Bundle * Android.OS.CancellationSignal -> Android.Content.Res.AssetFileDescriptor
override this.OpenTypedAssetFile : Android.Net.Uri * string * Android.OS.Bundle * Android.OS.CancellationSignal -> Android.Content.Res.AssetFileDescriptor
Parameters
- uri
- Uri
The data in the content provider being queried.
- mimeTypeFilter
- String
The type of data the client desires. May be a pattern, such as /, if the caller does not have specific type requirements; in this case the content provider will pick its best type matching the pattern.
- opts
- Bundle
Additional options from the client. The definitions of these are specific to the content provider being called.
- signal
- CancellationSignal
A signal to cancel the operation in progress, or
null
if none. For example, if you are downloading a
file from the network to service a "rw" mode request, you
should periodically call
CancellationSignal#throwIfCanceled()
to check whether
the client has canceled the request and abort the download.
Returns
Returns a new AssetFileDescriptor from which the client can read data of the desired type.
- Attributes
Exceptions
Throws FileNotFoundException if there is no file associated with the given URI or the mode is invalid.
Throws SecurityException if the caller does not have permission to access the data.
Throws IllegalArgumentException if the content provider does not support the requested MIME type.
Remarks
Called by a client to open a read-only stream containing data of a particular MIME type. This is like #openAssetFile(Uri, String)
, except the file can only be read-only and the content provider may perform data conversions to generate data of the desired type.
The default implementation compares the given mimeType against the result of #getType(Uri)
and, if they match, simply calls #openAssetFile(Uri, String)
.
See ClipData
for examples of the use and implementation of this method.
The returned AssetFileDescriptor can be a pipe or socket pair to enable streaming of data.
<p class="note">For better interoperability with other applications, it is recommended that for any URIs that can be opened, you also support queries on them containing at least the columns specified by android.provider.OpenableColumns
. You may also want to support other common columns if you have additional meta-data to supply, such as android.provider.MediaStore.MediaColumns#DATE_ADDED
in android.provider.MediaStore.MediaColumns
.
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.
See also
- <xref:Android.Content.ContentProvider.GetStreamTypes(Android.Net.Uri%2c+System.String)>
- <xref:Android.Content.ContentProvider.OpenAssetFile(Android.Net.Uri%2c+System.String)>
- <xref:Android.Content.ClipDescription.CompareMimeTypes(System.String%2c+System.String)>