openFile

open fun openFile(uri: Uri, mode: String): ParcelFileDescriptor

Override this to handle requests to open a file blob.

This method returns a ParcelFileDescriptor, which is returned directly to the caller. This way large data (such as images and documents) can be returned without copying the content.

The returned ParcelFileDescriptor is owned by the caller, so it is their responsibility to close it when done. That is, the implementation of this method should create a new ParcelFileDescriptor for each call.

Return

Returns a new ParcelFileDescriptor which you can use to access the file.

Parameters

uri

The URI whose file is to be opened.

mode

Access mode for the file. May be "r" for read-only access, "rw" for read and write access, or "rwt" for read and write access that truncates any existing file.

See also

openAssetFile(android.net.Uri, String)
openFileHelper(android.net.Uri, String)

Throws

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.