Open special folder with intent

I want to open a specific path folder with an Intent, I used the code for File Explorer and it worked fine, but on some device (samsung devices) if the file explorer app is not available then it does not open the specific path folder. I tried many solutions but it doesn't work for me.

Uri uri = Uri.fromFile(new File(new File(filePath).getParent()));
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "resource/folder");


        if (intent.resolveActivityInfo(getPackageManager(), 0) != null)
        {
            startActivity(intent);
        }
        else {

           Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
           intent.setDataAndType(uri, "file/*");
           startActivity(Intent.createChooser(intent, "Open folder"));

        }

      

+3


source to share





All Articles