Android-使用文件选择器打开特定的文件夹

时间:2018-09-20 12:49:08

标签: android filechooser

是否可以启动意图文件选择器并开始浏览从特定文件夹开始的文件?

我尝试使用:

    Uri selectedUri = Uri.parse("content://" + FileManager.mainDirectory.getAbsolutePath());
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT, selectedUri);
    intent.setType("*/*");
    startActivity(intent);

还尝试了FileProvider:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intent.setData(FileProvider.getUriForFile(getApplicationContext(),"com.xxx.xxx.provider",Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)));
startActivity(Intent.createChooser(intent,"open"));

我尝试了各种“ ACTION _...”选项以及我能找到的任何方法。 结果是从“最近”文件夹而不是我想要的特定文件夹(位于“文档”中)开始打开了文件选择器。 我正在Android 7上使用Samsung平板电脑。

0 个答案:

没有答案
相关问题