【问题标题】:How to open a folder create within application in android如何在android中打开在应用程序中创建的文件夹
【发布时间】:2018-07-31 10:26:34
【问题描述】:

我生成了一个文件夹名称“tesApplication”并在其中创建一个文件名“testFile.csc”并将一些日期存储到该文件中。现在我想使用新意图打开文件夹目录。 我尝试了下面的代码,但在我的情况下没有任何其他方式来实现这一点。

Uri selectedUri = Uri.parse(fileNameString);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(selectedUri, "text/csv");

    if (intent.resolveActivityInfo(getPackageManager(), 0) != null)
    {
        startActivity(intent);
    }
    else
    {
        // if you reach this place, it means there is no any file
        // explorer app installed on your device
    }

【问题讨论】:

  • 你想要的东西是不可能的。 Android 不提供此选项。

标签: android file directory


【解决方案1】:

复制到 else

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2015-12-28
  • 2013-12-29
  • 2016-08-01
  • 2014-05-11
  • 1970-01-01
  • 2015-06-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多