You can use Intent.ACTION_OPEN_DOCUMENT
,
Each document is represented as a content:// URI backed by a DocumentsProvider
, which can be opened as a stream with openFileDescriptor(Uri, String)
, or queried for DocumentsContract.Document metadata.
All selected documents are returned to the calling application with persistable read and write permission grants. If you want to maintain access to the documents across device reboots, you need to explicitly take the persistable permissions using takePersistableUriPermission(Uri, int)
.
Callers must indicate the acceptable document MIME types through setType(String). For example, to select photos, use image/*. If multiple disjoint MIME types are acceptable, define them in EXTRA_MIME_TYPES
and setType(String)
to /.
For the more details, please refer this link
Note that above mentioned is only available on API Level 19+.
Have a look at this also, how to pick few type of file via intent in android?