0

I'm trying to use the file chooser of intent in my Android application. Running the application, the file chooser just opens in the last used folder of the device and not in the prespecified folder. How can i make the file chooser open in the prespecified folder in every case? Here my code:

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + "prespecified/folder");
    intent.setDataAndType(uri, "*/*");

    startActivityForResult(Intent.createChooser(intent, "Choose file"), 123);
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • You can not. Only on Android 8 i believe. Moreover you indicated a file system path That will of course never do. – greenapps Mar 06 '18 at 12:07

1 Answers1

1

Running the application, the file chooser just opens in the last used folder of the device and not in the prespecified folder.

ACTION_GET_CONTENT does not take a Uri, let alone a broken one like you are supplying.

How can i make the file chooser open in the prespecified folder in every case?

You don't, at least via a platform Intent action. Those actions are for picking a piece of content and have little to do with files on the filesystem. Perhaps you should use a file chooser library instead.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491