added in [version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)   
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1 Summary: [Inherited Constants](https://developer.android.com/reference/android/support/v4/content/FileProvider#inhconstants) \| [Ctors](https://developer.android.com/reference/android/support/v4/content/FileProvider#pubctors) \| [Methods](https://developer.android.com/reference/android/support/v4/content/FileProvider#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/support/v4/content/FileProvider#inhmethods) \| [\[Expand All\]](https://developer.android.com/reference/android/support/v4/content/FileProvider#)

# FileProvider


`
public


class
FileProvider
`


`


`

`

extends https://developer.android.com/reference/android/content/ContentProvider.html


`

`


`

|---|---|---|
| java.lang.Object |||
| ↳ | [android.content.ContentProvider](https://developer.android.com/reference/android/content/ContentProvider.html) ||
|   | ↳ | android.support.v4.content.FileProvider |

<br />

*** ** * ** ***

FileProvider is a special subclass of `https://developer.android.com/reference/android/content/ContentProvider.html` that facilitates secure sharing
of files associated with an app by creating a `content://` `https://developer.android.com/reference/android/net/Uri.html` for a file
instead of a `file:///` `https://developer.android.com/reference/android/net/Uri.html`.


A content URI allows you to grant read and write access using
temporary access permissions. When you create an `https://developer.android.com/reference/android/content/Intent.html` containing
a content URI, in order to send the content URI
to a client app, you can also call `https://developer.android.com/reference/android/content/Intent.html#setFlags(int)` to add
permissions. These permissions are available to the client app for as long as the stack for
a receiving `https://developer.android.com/reference/android/app/Activity.html` is active. For an `https://developer.android.com/reference/android/content/Intent.html` going to a
`https://developer.android.com/reference/android/app/Service.html`, the permissions are available as long as the
`https://developer.android.com/reference/android/app/Service.html` is running.


In comparison, to control access to a `file:///` `https://developer.android.com/reference/android/net/Uri.html` you have to modify the
file system permissions of the underlying file. The permissions you provide become available to
*any* app, and remain in effect until you change them. This level of access is
fundamentally insecure.


The increased level of file access security offered by a content URI
makes FileProvider a key part of Android's security infrastructure.


This overview of FileProvider includes the following topics:

1. [Defining a FileProvider](https://developer.android.com/reference/android/support/v4/content/FileProvider#ProviderDefinition)
2. [Specifying Available Files](https://developer.android.com/reference/android/support/v4/content/FileProvider#SpecifyFiles)
3. [Retrieving the Content URI for a File](https://developer.android.com/reference/android/support/v4/content/FileProvider#GetUri)
[](https://developer.android.com/reference/android/support/v4/content/FileProvider#GetUri)
4. [](https://developer.android.com/reference/android/support/v4/content/FileProvider#GetUri)[Granting Temporary Permissions to a URI](https://developer.android.com/reference/android/support/v4/content/FileProvider#Permissions)
5. [Serving a Content URI to Another App](https://developer.android.com/reference/android/support/v4/content/FileProvider#ServeUri)

### Defining a FileProvider


Since the default functionality of FileProvider includes content URI generation for files, you
don't need to define a subclass in code. Instead, you can include a FileProvider in your app
by specifying it entirely in XML. To specify the FileProvider component itself, add a
`https://developer.android.com/guide/topics/manifest/provider-element`
element to your app manifest. Set the `android:name` attribute to
`android.support.v4.content.FileProvider`. Set the `android:authorities`
attribute to a URI authority based on a domain you control; for example, if you control the
domain `mydomain.com` you should use the authority
`com.mydomain.fileprovider`. Set the `android:exported` attribute to
`false`; the FileProvider does not need to be public. Set the
[android:grantUriPermissions](https://developer.android.com/guide/topics/manifest/provider-element#gprmsn) attribute to `true`, to allow you
to grant temporary access to files. For example:

```
<manifest>
    ...
    <application>
        ...
        <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="com.mydomain.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            ...
        </provider>
        ...
    </application>
</manifest>
```


If you want to override any of the default behavior of FileProvider methods, extend
the FileProvider class and use the fully-qualified class name in the `android:name`
attribute of the `<provider>` element.

### Specifying Available Files

A FileProvider can only generate a content URI for files in directories that you specify beforehand. To specify a directory, specify its storage area and path in XML, using child elements of the `<paths>` element. For example, the following `paths` element tells FileProvider that you intend to request content URIs for the `images/` subdirectory of your private file area.

```
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <files-path name="my_images" path="images/"/>
    ...
</paths>
```


The `<paths>` element must contain one or more of the following child elements:


```
<files-path name="name" path="path" />
```

:
    Represents files in the `files/` subdirectory of your app's internal storage
    area. This subdirectory is the same as the value returned by `https://developer.android.com/reference/android/content/Context.html#getFilesDir()`.


```
<cache-path name="name" path="path" />
```


:
    Represents files in the cache subdirectory of your app's internal storage area. The root path
    of this subdirectory is the same as the value returned by `https://developer.android.com/reference/android/content/Context.html#getCacheDir()`.


```
<external-path name="name" path="path" />
```

:
    Represents files in the root of the external storage area. The root path of this subdirectory
    is the same as the value returned by
    `https://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()`.


```
<external-files-path name="name" path="path" />
```

:
    Represents files in the root of your app's external storage area. The root path of this
    subdirectory is the same as the value returned by
    `Context#getExternalFilesDir(String) Context.getExternalFilesDir(null)`.


```
<external-cache-path name="name" path="path" />
```

:
    Represents files in the root of your app's external cache area. The root path of this
    subdirectory is the same as the value returned by
    `https://developer.android.com/reference/android/content/Context.html#getExternalCacheDir()`.


```
<external-media-path name="name" path="path" />
```

:
    Represents files in the root of your app's external media area. The root path of this
    subdirectory is the same as the value returned by the first result of
    `https://developer.android.com/reference/android/content/Context.html#getExternalMediaDirs()`.

    **Note:** this directory is only available on API 21+ devices.


These child elements all use the same attributes:


`name="*name*"`
:
    A URI path segment. To enforce security, this value hides the name of the subdirectory
    you're sharing. The subdirectory name for this value is contained in the
    `path` attribute.


`path="*path*"`
:
    The subdirectory you're sharing. While the `name` attribute is a URI path
    segment, the `path` value is an actual subdirectory name. Notice that the
    value refers to a **subdirectory**, not an individual file or files. You can't
    share a single file by its file name, nor can you specify a subset of files using
    wildcards.


You must specify a child element of `<paths>` for each directory that contains
files for which you want content URIs. For example, these XML elements specify two directories:

```
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <files-path name="my_images" path="images/"/>
    <files-path name="my_docs" path="docs/"/>
</paths>
```


Put the `<paths>` element and its children in an XML file in your project.
For example, you can add them to a new file called `res/xml/file_paths.xml`.
To link this file to the FileProvider, add a
[\<meta-data\>](https://developer.android.com/guide/topics/manifest/meta-data-element) element
as a child of the `<provider>` element that defines the FileProvider. Set the
`<meta-data>` element's "android:name" attribute to
`android.support.FILE_PROVIDER_PATHS`. Set the element's "android:resource" attribute
to `@xml/file_paths` (notice that you don't specify the `.xml`
extension). For example:

```
<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="com.mydomain.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths" />
</provider>
```

### Generating the Content URI for a File


To share a file with another app using a content URI, your app has to generate the content URI.
To generate the content URI, create a new `https://developer.android.com/reference/java/io/File` for the file, then pass the `https://developer.android.com/reference/java/io/File`
to `https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)`. You can send the content URI
returned by `https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)` to another app in an
`https://developer.android.com/reference/android/content/Intent.html`. The client app that receives the content URI can open the file
and access its contents by calling
`https://developer.android.com/reference/android/content/ContentResolver.html#openFileDescriptor(android.net.Uri, java.lang.String)` to get a `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html`.


For example, suppose your app is offering files to other apps with a FileProvider that has the
authority `com.mydomain.fileprovider`. To get a content URI for the file
`default_image.jpg` in the `images/` subdirectory of your internal storage
add the following code:

```
File imagePath = new File(Context.getFilesDir(), "images");
File newFile = new File(imagePath, "default_image.jpg");
Uri contentUri = getUriForFile(getContext(), "com.mydomain.fileprovider", newFile);
```
As a result of the previous snippet, `https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)` returns the content URI `content://com.mydomain.fileprovider/my_images/default_image.jpg`.

### Granting Temporary Permissions to a URI

To grant an access permission to a content URI returned from `https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)`, do one of the following:

- Call the method `https://developer.android.com/reference/android/content/Context.html#grantUriPermission(java.lang.String, android.net.Uri, int)` for the `content://` `https://developer.android.com/reference/android/net/Uri.html`, using the desired mode flags. This grants temporary access permission for the content URI to the specified package, according to the value of the the `mode_flags` parameter, which you can set to `https://developer.android.com/reference/android/content/Intent.html#FLAG_GRANT_READ_URI_PERMISSION`, `https://developer.android.com/reference/android/content/Intent.html#FLAG_GRANT_WRITE_URI_PERMISSION` or both. The permission remains in effect until you revoke it by calling `https://developer.android.com/reference/android/content/Context.html#revokeUriPermission(android.net.Uri, int)` or until the device reboots.
- Put the content URI in an `https://developer.android.com/reference/android/content/Intent.html` by calling `https://developer.android.com/reference/android/content/Intent.html#setData(android.net.Uri)`.
- Next, call the method `https://developer.android.com/reference/android/content/Intent.html#setFlags(int)` with either `https://developer.android.com/reference/android/content/Intent.html#FLAG_GRANT_READ_URI_PERMISSION` or `https://developer.android.com/reference/android/content/Intent.html#FLAG_GRANT_WRITE_URI_PERMISSION` or both.
- Finally, send the `https://developer.android.com/reference/android/content/Intent.html` to another app. Most often, you do this by calling `https://developer.android.com/reference/android/app/Activity.html#setResult(int, android.content.Intent)`.


  Permissions granted in an `https://developer.android.com/reference/android/content/Intent.html` remain in effect while the stack of the receiving
  `https://developer.android.com/reference/android/app/Activity.html` is active. When the stack finishes, the permissions are
  automatically removed. Permissions granted to one `https://developer.android.com/reference/android/app/Activity.html` in a client
  app are automatically extended to other components of that app.

### Serving a Content URI to Another App


There are a variety of ways to serve the content URI for a file to a client app. One common way
is for the client app to start your app by calling
`https://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int, android.os.Bundle)`,
which sends an `https://developer.android.com/reference/android/content/Intent.html` to your app to start an `https://developer.android.com/reference/android/app/Activity.html` in your app.
In response, your app can immediately return a content URI to the client app or present a user
interface that allows the user to pick a file. In the latter case, once the user picks the file
your app can return its content URI. In both cases, your app returns the content URI in an
`https://developer.android.com/reference/android/content/Intent.html` sent via `https://developer.android.com/reference/android/app/Activity.html#setResult(int, android.content.Intent)`.


You can also put the content URI in a `https://developer.android.com/reference/android/content/ClipData.html` object and then add the
object to an `https://developer.android.com/reference/android/content/Intent.html` you send to a client app. To do this, call
`https://developer.android.com/reference/android/content/Intent.html#setClipData(android.content.ClipData)`. When you use this approach, you can
add multiple `https://developer.android.com/reference/android/content/ClipData.html` objects to the `https://developer.android.com/reference/android/content/Intent.html`, each with its own
content URI. When you call `https://developer.android.com/reference/android/content/Intent.html#setFlags(int)` on the `https://developer.android.com/reference/android/content/Intent.html`
to set temporary access permissions, the same permissions are applied to all of the content
URIs.


**Note:** The `https://developer.android.com/reference/android/content/Intent.html#setClipData(android.content.ClipData)` method is
only available in platform version 16 (Android 4.1) and later. If you want to maintain
compatibility with previous versions, you should send one content URI at a time in the
`https://developer.android.com/reference/android/content/Intent.html`. Set the action to `https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND` and put the URI in data by calling
`https://developer.android.com/reference/android/content/Intent.html#setData(android.net.Uri)`.

### More Information


To learn more about FileProvider, see the Android training class
[Sharing Files Securely with URIs](https://developer.android.com/training/secure-file-sharing).

<br />

## Summary

### Inherited constants

[![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/content/FileProvider#)From interface `
android.content.ComponentCallbacks2
` `int` `TRIM_MEMORY_BACKGROUND`


`int` `TRIM_MEMORY_COMPLETE`


`int` `TRIM_MEMORY_MODERATE`


`int` `TRIM_MEMORY_RUNNING_CRITICAL`


`int` `TRIM_MEMORY_RUNNING_LOW`


`int` `TRIM_MEMORY_RUNNING_MODERATE`


`int` `TRIM_MEMORY_UI_HIDDEN`


| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/support/v4/content/FileProvider#FileProvider()() ` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/support/v4/content/FileProvider#attachInfo(android.content.Context, android.content.pm.ProviderInfo)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/content/pm/ProviderInfo.html info) ` After the FileProvider is instantiated, this method is called to provide the system with information about the provider. |
| ` int` | ` https://developer.android.com/reference/android/support/v4/content/FileProvider#delete(android.net.Uri, java.lang.String, java.lang.String[])(https://developer.android.com/reference/android/net/Uri.html uri, String selection, String[] selectionArgs) ` Deletes the file associated with the specified content URI, as returned by `https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)`. |
| ` String` | ` https://developer.android.com/reference/android/support/v4/content/FileProvider#getType(android.net.Uri)(https://developer.android.com/reference/android/net/Uri.html uri) ` Returns the MIME type of a content URI returned by `https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)`. |
| ` static https://developer.android.com/reference/android/net/Uri.html` | ` https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)(https://developer.android.com/reference/android/content/Context.html context, String authority, File file) ` Return a content URI for a given `https://developer.android.com/reference/java/io/File`. |
| ` https://developer.android.com/reference/android/net/Uri.html` | ` https://developer.android.com/reference/android/support/v4/content/FileProvider#insert(android.net.Uri, android.content.ContentValues)(https://developer.android.com/reference/android/net/Uri.html uri, https://developer.android.com/reference/android/content/ContentValues.html values) ` By default, this method throws an `https://developer.android.com/reference/java/lang/UnsupportedOperationException`. |
| ` boolean` | ` https://developer.android.com/reference/android/support/v4/content/FileProvider#onCreate()() ` The default FileProvider implementation does not need to be initialized. |
| ` https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` | ` https://developer.android.com/reference/android/support/v4/content/FileProvider#openFile(android.net.Uri, java.lang.String)(https://developer.android.com/reference/android/net/Uri.html uri, String mode) ` By default, FileProvider automatically returns the `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` for a file associated with a `content://` `https://developer.android.com/reference/android/net/Uri.html`. |
| ` https://developer.android.com/reference/android/database/Cursor.html` | ` https://developer.android.com/reference/android/support/v4/content/FileProvider#query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String)(https://developer.android.com/reference/android/net/Uri.html uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) ` Use a content URI returned by `https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)` to get information about a file managed by the FileProvider. |
| ` int` | ` https://developer.android.com/reference/android/support/v4/content/FileProvider#update(android.net.Uri, android.content.ContentValues, java.lang.String, java.lang.String[])(https://developer.android.com/reference/android/net/Uri.html uri, https://developer.android.com/reference/android/content/ContentValues.html values, String selection, String[] selectionArgs) ` By default, this method throws an `https://developer.android.com/reference/java/lang/UnsupportedOperationException`. |

### Inherited methods

[![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/content/FileProvider#)From class `

https://developer.android.com/reference/android/content/ContentProvider.html

` `


https://developer.android.com/reference/android/content/ContentProviderResult.html` `
applyBatch(ArrayList<https://developer.android.com/reference/android/content/ContentProviderOperation.html> arg0)
` `


void` `
attachInfo(https://developer.android.com/reference/android/content/Context.html arg0, https://developer.android.com/reference/android/content/pm/ProviderInfo.html arg1)
` `


int` `
bulkInsert(https://developer.android.com/reference/android/net/Uri.html arg0, https://developer.android.com/reference/android/content/ContentValues.html arg1)
` `


https://developer.android.com/reference/android/os/Bundle.html` `
call(String arg0, String arg1, https://developer.android.com/reference/android/os/Bundle.html arg2)
` `


https://developer.android.com/reference/android/net/Uri.html` `
canonicalize(https://developer.android.com/reference/android/net/Uri.html arg0)
` `
abstract


int` `
delete(https://developer.android.com/reference/android/net/Uri.html arg0, String arg1, String[] arg2)
` `


void` `
dump(FileDescriptor arg0, PrintWriter arg1, String[] arg2)
` `


final

String` `
getCallingPackage()
` `


final

https://developer.android.com/reference/android/content/Context.html` `
getContext()
` `


final

https://developer.android.com/reference/android/content/pm/PathPermission.html` `
getPathPermissions()
` `


final

String` `
getReadPermission()
` `


String[]` `
getStreamTypes(https://developer.android.com/reference/android/net/Uri.html arg0, String arg1)
` `
abstract


String` `
getType(https://developer.android.com/reference/android/net/Uri.html arg0)
` `


final

String` `
getWritePermission()
` `
abstract


https://developer.android.com/reference/android/net/Uri.html` `
insert(https://developer.android.com/reference/android/net/Uri.html arg0, https://developer.android.com/reference/android/content/ContentValues.html arg1)
` `


boolean` `
isTemporary()
` `


void` `
onConfigurationChanged(https://developer.android.com/reference/android/content/res/Configuration.html arg0)
` `
abstract


boolean` `
onCreate()
` `


void` `
onLowMemory()
` `


void` `
onTrimMemory(int arg0)
` `


https://developer.android.com/reference/android/content/res/AssetFileDescriptor.html` `
openAssetFile(https://developer.android.com/reference/android/net/Uri.html arg0, String arg1, https://developer.android.com/reference/android/os/CancellationSignal.html arg2)
` `


https://developer.android.com/reference/android/content/res/AssetFileDescriptor.html` `
openAssetFile(https://developer.android.com/reference/android/net/Uri.html arg0, String arg1)
` `


https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` `
openFile(https://developer.android.com/reference/android/net/Uri.html arg0, String arg1, https://developer.android.com/reference/android/os/CancellationSignal.html arg2)
` `


https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` `
openFile(https://developer.android.com/reference/android/net/Uri.html arg0, String arg1)
` `


final

https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` `
openFileHelper(https://developer.android.com/reference/android/net/Uri.html arg0, String arg1)
` `


<T>
https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` `
openPipeHelper(https://developer.android.com/reference/android/net/Uri.html arg0, String arg1, https://developer.android.com/reference/android/os/Bundle.html arg2, T arg3, https://developer.android.com/reference/android/content/ContentProvider.PipeDataWriter.html<T> arg4)
` `


https://developer.android.com/reference/android/content/res/AssetFileDescriptor.html` `
openTypedAssetFile(https://developer.android.com/reference/android/net/Uri.html arg0, String arg1, https://developer.android.com/reference/android/os/Bundle.html arg2)
` `


https://developer.android.com/reference/android/content/res/AssetFileDescriptor.html` `
openTypedAssetFile(https://developer.android.com/reference/android/net/Uri.html arg0, String arg1, https://developer.android.com/reference/android/os/Bundle.html arg2, https://developer.android.com/reference/android/os/CancellationSignal.html arg3)
` `


https://developer.android.com/reference/android/database/Cursor.html` `
query(https://developer.android.com/reference/android/net/Uri.html arg0, String[] arg1, https://developer.android.com/reference/android/os/Bundle.html arg2, https://developer.android.com/reference/android/os/CancellationSignal.html arg3)
` `


https://developer.android.com/reference/android/database/Cursor.html` `
query(https://developer.android.com/reference/android/net/Uri.html arg0, String[] arg1, String arg2, String[] arg3, String arg4, https://developer.android.com/reference/android/os/CancellationSignal.html arg5)
` `
abstract


https://developer.android.com/reference/android/database/Cursor.html` `
query(https://developer.android.com/reference/android/net/Uri.html arg0, String[] arg1, String arg2, String[] arg3, String arg4)
` `


boolean` `
refresh(https://developer.android.com/reference/android/net/Uri.html arg0, https://developer.android.com/reference/android/os/Bundle.html arg1, https://developer.android.com/reference/android/os/CancellationSignal.html arg2)
` `


final

void` `
setPathPermissions(https://developer.android.com/reference/android/content/pm/PathPermission.html arg0)
` `


final

void` `
setReadPermission(String arg0)
` `


final

void` `
setWritePermission(String arg0)
` `


void` `
shutdown()
` `


https://developer.android.com/reference/android/net/Uri.html` `
uncanonicalize(https://developer.android.com/reference/android/net/Uri.html arg0)
` `
abstract


int` `
update(https://developer.android.com/reference/android/net/Uri.html arg0, https://developer.android.com/reference/android/content/ContentValues.html arg1, String arg2, String[] arg3)
` [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/content/FileProvider#)From class `

java.lang.Object

` `


Object` `
clone()
` `


boolean` `
equals(Object arg0)
` `


void` `
finalize()
` `


final

Class<?>` `
getClass()
` `


int` `
hashCode()
` `


final

void` `
notify()
` `


final

void` `
notifyAll()
` `


String` `
toString()
` `


final

void` `
wait(long arg0, int arg1)
` `


final

void` `
wait(long arg0)
` `


final

void` `
wait()
` [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/content/FileProvider#)From interface `

https://developer.android.com/reference/android/content/ComponentCallbacks2.html

` `
abstract


void` `
onTrimMemory(int arg0)
` [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/content/FileProvider#)From interface `

https://developer.android.com/reference/android/content/ComponentCallbacks.html

` `
abstract


void` `
onConfigurationChanged(https://developer.android.com/reference/android/content/res/Configuration.html arg0)
` `
abstract


void` `
onLowMemory()
`

## Public constructors

### FileProvider

added in [version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
FileProvider ()
```

<br />

<br />

## Public methods

### attachInfo

```
void attachInfo (Context context, 
                ProviderInfo info)
```

After the FileProvider is instantiated, this method is called to provide the system with
information about the provider.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: A `https://developer.android.com/reference/android/content/Context.html` for the current component. <br /> |
| `info` | `ProviderInfo`: A `https://developer.android.com/reference/android/content/pm/ProviderInfo.html` for the new provider. <br /> |

### delete

added in [version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
int delete (Uri uri, 
                String selection, 
                String[] selectionArgs)
```

Deletes the file associated with the specified content URI, as
returned by `https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)`. Notice that this
method does **not** throw an `https://developer.android.com/reference/java/io/IOException`; you must check its return value.

<br />

| Parameters ||
|---|---|
| `uri` | `Uri`: A content URI for a file, as returned by `https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)`. <br /> |
| `selection` | `String`: Ignored. Set to `null`. <br /> |
| `selectionArgs` | `String`: Ignored. Set to `null`. <br /> |

| Returns ||
|---|---|
| `int` | 1 if the delete succeeds; otherwise, 0. <br /> |

### getType

added in [version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
String getType (Uri uri)
```

Returns the MIME type of a content URI returned by
`https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)`.

<br />

| Parameters ||
|---|---|
| `uri` | `Uri`: A content URI returned by `https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)`. <br /> |

| Returns ||
|---|---|
| `String` | If the associated file has an extension, the MIME type associated with that extension; otherwise `application/octet-stream`. <br /> |

### getUriForFile

added in [version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
Uri getUriForFile (Context context, 
                String authority, 
                File file)
```

Return a content URI for a given `https://developer.android.com/reference/java/io/File`. Specific temporary
permissions for the content URI can be set with
`https://developer.android.com/reference/android/content/Context.html#grantUriPermission(java.lang.String, android.net.Uri, int)`, or added
to an `https://developer.android.com/reference/android/content/Intent.html` by calling `https://developer.android.com/reference/android/content/Intent.html#setData(android.net.Uri)` and then
`https://developer.android.com/reference/android/content/Intent.html#setFlags(int)`; in both cases, the applicable flags are
`https://developer.android.com/reference/android/content/Intent.html#FLAG_GRANT_READ_URI_PERMISSION` and
`https://developer.android.com/reference/android/content/Intent.html#FLAG_GRANT_WRITE_URI_PERMISSION`. A FileProvider can only return a
`content` `https://developer.android.com/reference/android/net/Uri.html` for file paths defined in their `<paths>`
meta-data element. See the Class Overview for more information.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: A `https://developer.android.com/reference/android/content/Context.html` for the current component. <br /> |
| `authority` | `String`: The authority of a `https://developer.android.com/reference/android/support/v4/content/FileProvider` defined in a `<provider>` element in your app's manifest. <br /> |
| `file` | `File`: A `https://developer.android.com/reference/java/io/File` pointing to the filename for which you want a `content` `https://developer.android.com/reference/android/net/Uri.html`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html` | A content URI for the file. <br /> |

| Throws ||
|---|---|
| `IllegalArgumentException` | When the given `https://developer.android.com/reference/java/io/File` is outside the paths supported by the provider. |

### insert

added in [version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
Uri insert (Uri uri, 
                ContentValues values)
```

By default, this method throws an `https://developer.android.com/reference/java/lang/UnsupportedOperationException`. You must
subclass FileProvider if you want to provide different functionality.

<br />

| Parameters ||
|---|---|
| `uri` | `Uri` <br /> |
| `values` | `ContentValues` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html` | <br /> |

### onCreate

added in [version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
boolean onCreate ()
```

The default FileProvider implementation does not need to be initialized. If you want to
override this method, you must provide your own subclass of FileProvider.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### openFile

```
ParcelFileDescriptor openFile (Uri uri, 
                String mode)
```

By default, FileProvider automatically returns the
`https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` for a file associated with a `content://`
`https://developer.android.com/reference/android/net/Uri.html`. To get the `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html`, call
`https://developer.android.com/reference/android/content/ContentResolver.html#openFileDescriptor(android.net.Uri, java.lang.String)`.

To override this method, you must provide your own subclass of FileProvider.

<br />

| Parameters ||
|---|---|
| `uri` | `Uri`: A content URI associated with a file, as returned by `https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)`. <br /> |
| `mode` | `String`: 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. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` | A new `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` with which you can access the file. <br /> |

| Throws ||
|---|---|
| `FileNotFoundException` |   |

### query

added in [version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
Cursor query (Uri uri, 
                String[] projection, 
                String selection, 
                String[] selectionArgs, 
                String sortOrder)
```

Use a content URI returned by
`https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)` to get information about a file
managed by the FileProvider.
FileProvider reports the column names defined in `https://developer.android.com/reference/android/provider/OpenableColumns.html`:

- `https://developer.android.com/reference/android/provider/OpenableColumns.html#DISPLAY_NAME`
- `https://developer.android.com/reference/android/provider/OpenableColumns.html#SIZE`

For more information, see `https://developer.android.com/reference/android/content/ContentProvider.html#query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String)`.

<br />

<br />

| Parameters ||
|---|---|
| `uri` | `Uri`: A content URI returned by `https://developer.android.com/reference/android/support/v4/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File)`. <br /> |
| `projection` | `String`: The list of columns to put into the `https://developer.android.com/reference/android/database/Cursor.html`. If null all columns are included. <br /> |
| `selection` | `String`: Selection criteria to apply. If null then all data that matches the content URI is returned. <br /> |
| `selectionArgs` | `String`: An array of `https://developer.android.com/reference/java/lang/String`, containing arguments to bind to the *selection* parameter. The *query* method scans *selection* from left to right and iterates through *selectionArgs*, replacing the current "?" character in *selection* with the value at the current position in *selectionArgs*. The values are bound to *selection* as `https://developer.android.com/reference/java/lang/String` values. <br /> |
| `sortOrder` | `String`: A `https://developer.android.com/reference/java/lang/String` containing the column name(s) on which to sort the resulting `https://developer.android.com/reference/android/database/Cursor.html`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/database/Cursor.html` | A `https://developer.android.com/reference/android/database/Cursor.html` containing the results of the query. <br /> |

### update

added in [version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
int update (Uri uri, 
                ContentValues values, 
                String selection, 
                String[] selectionArgs)
```

By default, this method throws an `https://developer.android.com/reference/java/lang/UnsupportedOperationException`. You must
subclass FileProvider if you want to provide different functionality.

<br />

| Parameters ||
|---|---|
| `uri` | `Uri` <br /> |
| `values` | `ContentValues` <br /> |
| `selection` | `String` <br /> |
| `selectionArgs` | `String` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

-

  ## Interfaces

  - [Loader.OnLoadCanceledListener](https://developer.android.com/reference/android/support/v4/content/Loader.OnLoadCanceledListener)
  - [Loader.OnLoadCompleteListener](https://developer.android.com/reference/android/support/v4/content/Loader.OnLoadCompleteListener)
-

  ## Classes

  - [AsyncTaskLoader](https://developer.android.com/reference/android/support/v4/content/AsyncTaskLoader)
  - [ContentResolverCompat](https://developer.android.com/reference/android/support/v4/content/ContentResolverCompat)
  - [ContextCompat](https://developer.android.com/reference/android/support/v4/content/ContextCompat)
  - [CursorLoader](https://developer.android.com/reference/android/support/v4/content/CursorLoader)
  - [FileProvider](https://developer.android.com/reference/android/support/v4/content/FileProvider)
  - [IntentCompat](https://developer.android.com/reference/android/support/v4/content/IntentCompat)
  - [Loader](https://developer.android.com/reference/android/support/v4/content/Loader)
  - [Loader.ForceLoadContentObserver](https://developer.android.com/reference/android/support/v4/content/Loader.ForceLoadContentObserver)
  - [LocalBroadcastManager](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager)
  - [MimeTypeFilter](https://developer.android.com/reference/android/support/v4/content/MimeTypeFilter)
  - [PermissionChecker](https://developer.android.com/reference/android/support/v4/content/PermissionChecker)
  - [SharedPreferencesCompat](https://developer.android.com/reference/android/support/v4/content/SharedPreferencesCompat)
  - [SharedPreferencesCompat.EditorCompat](https://developer.android.com/reference/android/support/v4/content/SharedPreferencesCompat.EditorCompat)
  - [WakefulBroadcastReceiver](https://developer.android.com/reference/android/support/v4/content/WakefulBroadcastReceiver)