I want to choose only pdf, xlsx and txt file from storage but intent.setType can do only one file(eg.txt file only (or) pdf file only). Is it possible to get all three files
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
http://developer.android.com/reference/android/content/Intent.html#ACTION_OPEN_DOCUMENT
Note that this is only available on API Level 19+.