- 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 (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.
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.
This is like ContentProvider.OpenFile(Android.Net.Uri, System.String), but can be implemented by providers that need to be able to return sub-sections of files, often assets inside of their .apk. This method can be called from multiple threads, as described in Processes and Threads.
If you implement this, your clients must be able to deal with such file slices, either directly with ContentResolver.OpenAssetFileDescriptor(Android.Net.Uri, System.String), or by using the higher-level ContentResolver.OpenInputStream(Android.Net.Uri) or ContentResolver.OpenOutputStream(Android.Net.Uri) methods.
The returned AssetFileDescriptor can be a pipe or socket pair to enable streaming of data.
If you are implementing this to return a full file, you should create the AssetFileDescriptor with Android.Content.Res.AssetFileDescriptor.UnknownLength to be compatible with applications that cannot handle sub-sections of files.
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.