View file directory
android.intent.action.VIEW
This intention is used to allow 3rd party apps to direct the user to a directory of the file system or document tree.
The location of the directory is either provided in the extra or as data uri.
The content uri (if provided) of the received intent can be used by the (file manager) app to retrieve the display name of the folder via OpenableColumns.DATA
. The file: scheme uri (if provided) can be used to determine the directory path if the extra was not provided.
It is the responsibility of the (file manager) app to decide whether it can display the directory or not (due to missing permissions or unknown location).
Note, file: scheme uris should not be used in apps targeted Android 24+, otherwise a FileUriExposedException
is thrown.
Note, for picking a directory or file, use OPEN_DOCUMENT,
OPEN_DOCUMENT_TREE or PICK_FILE.
Use
public void startViewFileDirectory(String absolutePath) { Intent intent = new Intent("android.intent.action.VIEW"); intent.setData(dataUri); // uri of directory from FileProvider, DocumentProvider or uri with file scheme, can be empty. intent.putExtra("org.openintents.extra.ABSOLUTE_PATH", absolutePath); // String if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } }
Example intent filter
<activity ...> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="vnd.android.documents/directory" /> </intent-filter> </activity>
Apps Providing an Implementation
Search on Google Play, AppBrain, Amazon App store or similar (not yet available - please make this happen!)
For Specification Writers
Edit on Github