Android.Content.ContentResolver.OpenAssetFileDescriptor Method
Open a raw file descriptor to access data under a URI.

Syntax

[Android.Runtime.Register("openAssetFileDescriptor", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;", "")]
public Android.Content.Res.AssetFileDescriptor OpenAssetFileDescriptor (Android.Net.Uri uri, string mode)

Parameters

uri
The desired URI to open.
mode
The file mode to use, as per ContentProvider.OpenAssetFile(Android.Net.Uri, System.String).

Returns

Documentation for this section has not yet been entered.

Exceptions

TypeReason
Java.IO.FileNotFoundExceptionThrows FileNotFoundException of no file exists under the URI or the mode is invalid.

Remarks

Open a raw file descriptor to access data under a URI. This interacts with the underlying ContentProvider.OpenAssetFile(Android.Net.Uri, System.String) method of the provider associated with the given URI, to retrieve any file stored there.

Accepts the following URI schemes:
The android.resource (ContentResolver.SchemeAndroidResource) Scheme

A Uri object can be used to reference a resource in an APK file. The Uri should be one of the following formats:

  • android.resource://package_name/id_number

    package_name is your package name as listed in your AndroidManifest.xml. For example com.example.myapp

    id_number is the int form of the ID.

    The easiest way to construct this form is

    java Example

    Uri uri = Uri.parse("android.resource://com.example.myapp/" + R.raw.my_resource");
  • android.resource://package_name/type/name

    package_name is your package name as listed in your AndroidManifest.xml. For example com.example.myapp

    type is the string form of the resource type. For example, raw or drawable. name is the string form of the resource name. That is, whatever the file name was in your res directory, without the type extension. The easiest way to construct this form is

    java Example

    Uri uri = Uri.parse("android.resource://com.example.myapp/raw/my_resource");

Note that if this function is called for read-only input (mode is "r") on a content: URI, it will instead call ContentResolver.OpenTypedAssetFileDescriptor(Android.Net.Uri, System.String, System.String) for you with a MIME type of "*/*". This allows such callers to benefit from any built-in data conversion that a provider implements.

[Android Documentation]

Requirements

Namespace: Android.Content
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 3