Langsung ke konten

Paling sering dikunjungi

Terakhir dikunjungi

navigation

Sharing Files

Dependencies and prerequisites

  • Android 1.6 (API Level 4) or higher
  • Familiarity with file operations such as opening, reading, and writing files

You should also read

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 component provides the method getUriForFile() 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 that contains the data. To learn how to send simple data with an Intent, see the training class Sharing Simple Data.

This class explains how to securely share files from your app to another app using content URIs generated by the Android FileProvider component and temporary permissions that you grant to the receiving app for the content URI.

Lessons

Setting Up File Sharing
Learn how to set up your app to share files.
Sharing a 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
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
Learn how an app can use a content URI generated by a FileProvider to retrieve file information including MIME type and file size.
Situs ini menggunakan cookies untuk menyimpan preferensi Anda tentang bahasa di situs tertentu dan opsi tampilan.

Dapatkan berita dan tips terbaru dari developer Android yang akan membantu Anda mencapai kesuksesan di Google Play.

* Wajib Diisi

Hore!

Ikuti Google Developers di WeChat

Buka situs ini dalam bahasa ?

Anda meminta halaman dalam bahasa , namun preferensi bahasa untuk situs ini adalah .

Ingin mengubah preferensi bahasa dan mengakses situs ini dalam bahasa ? Jika nanti Anda ingin mengubah preferensi bahasa, gunakan menu bahasa di bagian bawah setiap halaman.

Kelas ini memerlukan tingkat API atau yang lebih tinggi

Dokumen ini tersembunyi karena level API yang Anda pilih untuk dokumentasi ini adalah . Anda dapat mengubah level API dokumentasi dengan pemilih di atas menu navigasi sebelah kiri.

Untuk informasi lebih lanjut tentang menentukan level API yang diperlukan aplikasi Anda, baca Mendukung Versi Platform Yang Berbeda.

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)