0

What I want

One of the features of my App is to Download files. I want to give the user the opportunity to open the folder, which contains the downloaded files, so that he can browse through them and open them in whatever application he likes. So I have a button, which should open a path to this directory in one of the installed file managers.

What I have

So far I've been referring to this solution: Android: How to open a specific folder via Intent and show its content in a file browser?

private fun openDirectoryInFileManager(directoryPath: String) {
    val intent = Intent(Intent.ACTION_VIEW)
    val uri = Uri.parse(directoryPath)
    intent.setDataAndType(uri, "*/*")
    startActivity(intent)
}

This code opens a pop-up window, which suggests all kinds of installed applications, to open that Uri. Screenshot of the pop-up window

So far I've been able to select the app Total Commander to open the Uri with and it took me right to the chosen directory. However, since a recent update of Total Commander this is not possible anymore. All the other installed file managers seem not to be able to open the path. They just open the Downloads directory, no matter which path is passed to them.

Is there a better solution to open any directory path in Android? Or does anyone know an application, which supports opening a handed directory path?

aminography
  • 21,986
  • 13
  • 70
  • 74

1 Answers1

0

which should open a path to this directory in one of the installed file managers

There is no requirement for an Android device to have a file manager app, let alone one that supports integration with third-party apps like yours.

So far I've been referring to this solution: Android: How to open a specific folder via Intent and show its content in a file browser?

Those answers are mostly incorrect. There is no requirement for any Android device to have an app that supports any of those Intent structures.

Is there a better solution to open any directory path in Android?

There has never been a reliable solution for starting a third-party file manager.

The best solution would be for you to have your own UI for listing the directory contents, then use ACTION_VIEW to allow the user to attempt to view a particular piece of content. There are a variety of libraries that may help you implement that.

Or does anyone know an application, which supports opening a handed directory path?

Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam.

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