I want to open the downloads folder of external files directory by most of the file manager applications. For this I tried this:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID, getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS));
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setDataAndType(uri, "*/*");
startActivity(Intent.createChooser(intent, "Open folder"));
And I added this provider in manifest file:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
Also there is provider_paths xml file content:
<paths>
<external-files-path
name="files"
path="." />
</paths>
But it opens the recent folder of the default Android file picker.
Please pay attention that I want to open a folder not a file.