0

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. enter image description here

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
}
Akash khan
  • 861
  • 13
  • 25
  • Can you show your complete code? – input Sep 08 '20 at 03:17
  • Please see in question the `openDirectory` is the complete method for the desired task but startActivity method shows it required 3 arguments. – Akash khan Sep 08 '20 at 03:58
  • You cannot supply a file uri as data for that intent. That will not work. There is an extra INITIALDIR which only takes a saf uri. But maybe not for your action. – blackapps Sep 08 '20 at 06:56

0 Answers0