![]() |
Jabber Guest Android SDK
|
Provider to support easy sharing of private files between apps. More...
Inherits ContentProvider.
Static Public Member Functions | |
static Uri | getUriForFile (Context context, String authority, File file) |
Return a Uri that provides access to the given File. More... | |
Detailed Description
Provider to support easy sharing of private files between apps.
When paired with features like Context#grantUriPermission(String, Uri, int) or Intent#FLAG_GRANT_READ_URI_PERMISSION, this provider ensures that receiving apps can always open the underlying file.
Apps should generally avoid sending raw filesystem paths across process boundaries, since the receiving app may not have the same access as the sender. Instead, apps should send Uri backed by a provider like FileProvider.
To use this provider, add it to your manifest:
{ development/samples/Support4Demos/AndroidManifest.xml file_provider_declaration}
And define one or more filesystem paths your provider should support in an XML resource. This provider will only support files which exist under these defined paths.
{ development/samples/Support4Demos/res/xml/my_paths.xml file_provider_paths_declaration}
Then use getUriForFile(Context, String, File) at runtime to generate a Uri backed by the provider. Since the provider is not exported, these Uri can only be accessed by other apps when you explicitly grant access.
Member Function Documentation
|
inlinestatic |
Return a Uri that provides access to the given File.
The returned Uri can be used with features like Context#grantUriPermission(String, Uri, int) or Intent#FLAG_GRANT_READ_URI_PERMISSION to allow other apps to access private files. Providers only support files which exist under filesystem paths defined in their
.
- Parameters
-
authority The authority of a FileProvider defined as a in your manifest.<provider>
- Exceptions
-
IllegalArgumentException When the given File is outside the paths supported by the provider.