Apps often have a need to offer one or more of their files to another app. For example, an image gallery may want to offer files to image editors, or a file management app may want to allow users to copy and paste files between areas in external storage. One way a sending app can share a file is to respond to a request from the receiving app.

In all cases, the only secure way to offer a file from your app to another app is to send the receiving app the file's content URI and grant temporary access permissions to that URI. Content URIs with temporary URI access permissions are secure because they apply only to the app that receives the URI, and they expire automatically. The Android[FileProvider](https://developer.android.com/reference/androidx/core/content/FileProvider)component provides the method[getUriForFile()](https://developer.android.com/reference/androidx/core/content/FileProvider#getUriForFile(android.content.Context, java.lang.String, java.io.File))for generating a file's content URI.

If you want to share small amounts of text or numeric data between apps, you should send an[Intent](https://developer.android.com/reference/android/content/Intent)that contains the data. To learn how to send simple data with an[Intent](https://developer.android.com/reference/android/content/Intent), see the training class[Sharing simple data](https://developer.android.com/training/sharing).

This class explains how to securely share files from your app to another app using content URIs generated by the Android[FileProvider](https://developer.android.com/reference/androidx/core/content/FileProvider)component and temporary permissions that you grant to the receiving app for the content URI.

## Lessons

**[Setting up file sharing](https://developer.android.com/training/secure-file-sharing/setup-sharing)**
:   Learn how to set up your app to share files.

**[Sharing a file](https://developer.android.com/training/secure-file-sharing/share-file)**
:   Learn how to offer a file to another app by generating a content URI for the file, granting access permissions to the URI, and sending the URI to the app.

**[Requesting a shared file](https://developer.android.com/training/secure-file-sharing/request-file)**
:   Learn how to request a file shared by another app, receive the content URI for the file, and use the content URI to open the file.

**[Retrieving file information](https://developer.android.com/training/secure-file-sharing/retrieve-info)**
:   Learn how an app can use a content URI generated by a[FileProvider](https://developer.android.com/reference/androidx/core/content/FileProvider)to retrieve file information including MIME type and file size.

For additional related information, refer to:

- [Storage Options](https://developer.android.com/guide/topics/data/data-storage)
- [Saving Files](https://developer.android.com/training/basics/data-storage/files)
- [Sharing Simple Data](https://developer.android.com/training/sharing)