In my app, I'm saving my application exported pdf file in SD-CARD/myapp
directory. I want to open that directory from my app in any filemanager installed in android device. So that user can easily move that directory easily to get those files exported by my app.
I have tried this code from Android: How to open a specific folder via Intent and show its content in a file browser? (Accepted answer)
private void openDirectory() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
+ File.separator + "myFolder" + File.separator);
intent.setDataAndType(uri, "text/csv");
startActivity(Intent.createChooser(intent, "Open folder"));
}
but it's showing me error on startActivity
Expected 3 arguments but found 1.
Tried also this code but everywhere it shows startActivity needs 3 arguments but found 1.
Uri selectedUri = Uri.parse(Environment.getExternalStorageDirectory() + "/myFolder/");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(selectedUri, "resource/folder");
if (intent.resolveActivityInfo(getPackageManager(), 0) != null)
{
startActivity(intent);
}
else
{
// if you reach this place, it means there is no any file
// explorer app installed on your device
}