android - 如何在android中找到根目录?
问题描述
在 Windows 中,我使用以下代码显示系统的所有根目录
import java.io.*;
public class GFG {
public static void main(String args[])
{
// roots of the path name
File root[] = File.listRoots();
// check if the root is null or not
if (root != null) {
System.out.print("Roots are: ");
// display the roots of the path name
for (int i = 0; i < root.length; i++) {
System.out.print(root[i].getPath() + " ");
}
}
else
System.out.println("There are no roots");
}
}
输出:
Roots are: C:\ D:\ E:\ F:\ G:\
但是,如何在 android 中显示?
我想显示内部存储路径、sdcard 存储路径之类的目录,或者如果我通过 usb display pendrive stroge path 连接 pendrive。
我想获取所有根目录的路径,如 sdcard path 、 internal storage path 和 usb pendrive path 。
我怎样才能做到这一点 ?
解决方案
推荐阅读
- r - 根据用户选择更改地图颜色填充
- ios - 用 UIAlertController 替换 UIAlertView
- machine-learning - 了解多元线性回归
- amazon-web-services - Traefik 集群还没有准备好用于生产吗?
- email - Gmail 垃圾邮件文件夹中的邮件登陆
- android - 如何设置确定圆形进度条的辅助颜色
- javascript - 将时间格式转换为秒
- continuous-integration - 使用 ci/cd 命令行在 gitlab 中提取或解压缩文件
- ruby-on-rails - 在 Google App Engine / Stackdriver 上显示和提醒 Rails 应用程序记录的错误
- java - Java泛型上限通配符限制