How to programatically open a folder in android?

2020-07-22 19:36发布

I am working on an Android application which opens folders,

My question is how can I open a folder programmatically in Android? .

I tried all the solutions available in stack-overflow and searched in Google but I couldn't find a solution. Can someone please provide me an answer?

Thanks in advance.

标签: java android
1条回答
太酷不给撩
2楼-- · 2020-07-22 19:45

you can open folder with use of following code

File file = new File(path);
        Uri uri_path = Uri.fromFile(file);
        String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension
                (MimeTypeMap.getFileExtensionFromUrl(path));


        Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
        intent.setType(mimeType);
        intent.setDataAndType(uri_path, mimeType);
        startActivity(intent);
查看更多
登录 后发表回答