How to simply open directory/folder?

后端 未结 2 728
余生分开走
余生分开走 2021-02-05 22:52

DONT mark this as duplicate, before reading what I need.

I have seen many similar topics, but in none of them I\'ve found solution. I need the simplest thing: In my app

相关标签:
2条回答
  • 2021-02-05 23:55

    The solution (not complete) I have found, was that I was missing file:// prefix. Here is my solution (however, it shows all kinds of applications on first view):

    public void openFolder(String location)
    {
        // location = "/sdcard/my_folder";
        Intent intent = new Intent(Intent.ACTION_VIEW);
        Uri mydir = Uri.parse("file://"+location);
        intent.setDataAndType(mydir,"application/*");    // or use */*
        startActivity(intent);
    }
    

    p.s. Strange and surprising, but there doesnt exist the standard definition of "File Browser" in stock Android systems (unless you install 3rd party "File Explorer").. That's why "resource/folder" mime-type doesnt work by default..

    However, let's say a simple truth. File-Browser is a SIMPLE and ESSENTIAL part of any OS system. And it's quite disrespectful from Android, saying that it's not their job, and throwing the responsiblity to 3rd party apps.

    0 讨论(0)
  • 2021-02-05 23:55

    You can use type DocumentsContract.Document.MIME_TYPE_DIR which works on several devices and launches File Explorer. You can refer this SO for more details.

    0 讨论(0)
提交回复
热议问题