android - 如何在android中打开在应用程序中创建的文件夹
问题描述
我生成了一个文件夹名称“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
}
解决方案
把这个复制到其他地方
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"));
}
推荐阅读
- node.js - 我正在使用 Node.JS,但期望 ')' 时出错。请问我该如何解决
- linux - 将 Open VMS FDL(文件定义语言)转换为 linux
- javascript - NGX Graph linkTemplate - 链接中间指针对齐问题
- html - 如何在 vue js 中创建自定义自动完成组件?
- javascript - 我想使用 Switch 语句在 Javascript 中查找元音出现
- php - jQuery 验证插件为 Google Recaptcha V.2 添加规则
- vue.js - 在 BootstrapVue 中关闭 Modal 时防止关闭 Toast
- visual-studio-code - 安装 Visual Code 2018 时出现驱动器错误
- python - 无法使用 docker-compose 在不同的端口运行 Python 烧瓶应用程序
- c# - 我使用 C# 和 WPF 的第一个项目 - 如何设置 .xaml.cs 中的变量以显示在文本框中?