- uri
- The URI whose file is to be opened.
- mode
- Access mode for the file. May be "r" for read-only access, "w" for write-only access, "rw" for read and write access, or "rwt" for read and write access that truncates any existing file.
- signal
- 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 Android.OS.CancellationSignal.ThrowIfCanceled to check whether the client has canceled the request and abort the download.
Documentation for this section has not yet been entered.
Type Reason Java.IO.FileNotFoundException Throws FileNotFoundException if there is no file associated with the given URI or the mode is invalid. Java.Lang.SecurityException Throws SecurityException if the caller does not have permission to access the file.
Override this to handle requests to open a file blob. The default implementation always throws Java.IO.FileNotFoundException. This method can be called from multiple threads, as described in Processes and Threads.
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.
If opened with the exclusive "r" or "w" modes, the returned ParcelFileDescriptor can be a pipe or socket pair to enable streaming of data. Opening with the "rw" or "rwt" modes implies a file on disk that supports seeking.
If you need to detect when the returned ParcelFileDescriptor has been closed, or if the remote process has crashed or encountered some other error, you can use Android.OS.ParcelFileDescriptor.Open(Java.IO.File, Android.OS.ParcelFileMode, Android.OS.ParcelFileMode, Android.OS.ParcelFileMode), Android.OS.ParcelFileDescriptor.CreateReliablePipe, or Android.OS.ParcelFileDescriptor.CreateReliableSocketPair.
For use in Intents, you will want to implement ContentProvider.GetType(Android.Net.Uri) to return the appropriate MIME type for the data returned here with the same URI. This will allow intent resolution to automatically determine the data MIME type and select the appropriate matching targets as part of its operation.
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 NoType:android/provider/MediaStore$MediaColumns;Href=../../../reference/android/provider/MediaStore.MediaColumns.html#DATE_ADDED in NoType:android/provider/MediaStore$MediaColumns;Href=../../../reference/android/provider/MediaStore.MediaColumns.html.