Resources.OpenRawResourceFd(Int32) Method

Definition

Open a file descriptor for reading a raw resource.

[Android.Runtime.Register("openRawResourceFd", "(I)Landroid/content/res/AssetFileDescriptor;", "GetOpenRawResourceFd_IHandler")]
public virtual Android.Content.Res.AssetFileDescriptor? OpenRawResourceFd (int id);
[<Android.Runtime.Register("openRawResourceFd", "(I)Landroid/content/res/AssetFileDescriptor;", "GetOpenRawResourceFd_IHandler")>]
abstract member OpenRawResourceFd : int -> Android.Content.Res.AssetFileDescriptor
override this.OpenRawResourceFd : int -> Android.Content.Res.AssetFileDescriptor

Parameters

id
Int32

The resource identifier to open, as generated by the aapt tool.

Returns

AssetFileDescriptor A new file descriptor you can use to read the resource. This includes the file descriptor itself, as well as the offset and length of data where the resource appears in the file. A null is returned if the file exists but is compressed.

Attributes

Exceptions

Throws NotFoundException if the given ID does not exist.

Remarks

Open a file descriptor for reading a raw resource. This can only be used with resources whose value is the name of an asset files -- that is, it can be used to open drawable, sound, and raw resources; it will fail on string and color resources.

This function only works for resources that are stored in the package as uncompressed data, which typically includes things like mp3 files and png images.

Java documentation for android.content.res.Resources.openRawResourceFd(int).

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