Umer Farooq
Umer Farooq

Reputation: 7486

Opening a file location directly with file explorer

How can I open a file/folder using default file explorer? For example: I have a folder whose path is/root/user/sd/mystuff, I want to open this path directly with the default file explorer. I have searched but didn't find any answer providing solution for this. So if I use setData&type instead of setType, will it open the provided path directly.

Intent intent = new Intent();
....
intent.setDataAndType(Uri.parse("file:/root/user/sd/mystuff), "file/*");
startActivity(intent);

Regards

Upvotes: 0

Views: 3400

Answers (1)

Prakhar
Prakhar

Reputation: 2310

you can do this to accomplish your task the code is given below..

public void openFolder()
{
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
    + "/myFolder/");
intent.setDataAndType(uri, " ");//specify your type
startActivity(Intent.createChooser(intent, "Open folder"));
}

Upvotes: 2

Related Questions