Open folder on card

前端 未结 2 720
耶瑟儿~
耶瑟儿~ 2021-01-07 00:55

I thought this was something really simple, but it\'s giving me more work than the rest of the whole app.

I just want a button to open the \"Downloaded Files\" folde

相关标签:
2条回答
  • 2021-01-07 01:29

    I think this one could work for you:

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
        + "/yourFolder/");
    intent.setDataAndType(uri, "*/*");
    startActivity(Intent.createChooser(intent, "Open /sdcard/yourFolder"));
    
    0 讨论(0)
  • 2021-01-07 01:37

    wow.. Finally!! After many things I tried, the only way it worked was by wrapping the URI string into a File first, and then do a Uri.fromFile:

    File file = new File(Environment.getExternalStorageDirectory().getPath() + "/MyDownloadedFiles/");
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "*/*");
    startActivity(Intent.createChooser(intent, getString(R.string.action_downloaded)));
    
    0 讨论(0)
提交回复
热议问题