ContentProvider.OpenAssetFile ContentProvider.OpenAssetFile Method

Definition

Overloads

OpenAssetFile(Uri, String) OpenAssetFile(Uri, String)

This is like OpenFile(Uri, String), but can be implemented by providers that need to be able to return sub-sections of files, often assets inside of their .apk.

OpenAssetFile(Uri, String, CancellationSignal) OpenAssetFile(Uri, String, CancellationSignal)

This is like OpenFile(Uri, String), but can be implemented by providers that need to be able to return sub-sections of files, often assets inside of their .apk.

OpenAssetFile(Uri, String) OpenAssetFile(Uri, String)

This is like OpenFile(Uri, String), but can be implemented by providers that need to be able to return sub-sections of files, often assets inside of their .apk.

[Android.Runtime.Register("openAssetFile", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;", "GetOpenAssetFile_Landroid_net_Uri_Ljava_lang_String_Handler", ApiSince=3)]
public virtual Android.Content.Res.AssetFileDescriptor OpenAssetFile (Android.Net.Uri uri, string mode);
abstract member OpenAssetFile : Android.Net.Uri * string -> Android.Content.Res.AssetFileDescriptor
override this.OpenAssetFile : Android.Net.Uri * string -> Android.Content.Res.AssetFileDescriptor

Parameters

uri
Uri Uri

The URI whose file is to be opened.

mode
String String

Access mode for the file. May be "r" for read-only access, "w" for write-only access (erasing whatever data is currently in the file), "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing data, and "rwt" for read and write access that truncates any existing file.

Returns

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 file.

Remarks

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

OpenAssetFile(Uri, String, CancellationSignal) OpenAssetFile(Uri, String, CancellationSignal)

This is like OpenFile(Uri, String), but can be implemented by providers that need to be able to return sub-sections of files, often assets inside of their .apk.

[Android.Runtime.Register("openAssetFile", "(Landroid/net/Uri;Ljava/lang/String;Landroid/os/CancellationSignal;)Landroid/content/res/AssetFileDescriptor;", "GetOpenAssetFile_Landroid_net_Uri_Ljava_lang_String_Landroid_os_CancellationSignal_Handler", ApiSince=19)]
public virtual Android.Content.Res.AssetFileDescriptor OpenAssetFile (Android.Net.Uri uri, string mode, Android.OS.CancellationSignal signal);
abstract member OpenAssetFile : Android.Net.Uri * string * Android.OS.CancellationSignal -> Android.Content.Res.AssetFileDescriptor
override this.OpenAssetFile : Android.Net.Uri * string * Android.OS.CancellationSignal -> Android.Content.Res.AssetFileDescriptor

Parameters

uri
Uri Uri

The URI whose file is to be opened.

mode
String String

Access mode for the file. May be "r" for read-only access, "w" for write-only access (erasing whatever data is currently in the file), "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing data, and "rwt" for read and write access that truncates any existing file.

signal
CancellationSignal 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 ThrowIfCanceled() to check whether the client has canceled the request and abort the download.

Returns

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 file.

Remarks

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

Applies to