【发布时间】:2021-02-22 12:30:03
【问题描述】:
所以我在访问根应用程序数据目录时遇到问题 我的示例目录: /data/app/com.android.chrome-jAB96abq4RXcFrKebL0BUQ==
我想在没有扩展名的情况下进入 /data/app/com.android.chrome 以获取列表文件夹 试过 /data/app/* com.android.chrome */ 但得到了 null
这是我的代码
String path = "/data/app/*com.android.chrome*";
File file = new File(path);
String[] dir = file.list();
for(int i=0;i<dir.length;i++) {
Toast.makeText(this, "File: "+dir[i], Toast.LENGTH_LONG).show();}
在此之前我已经将权限更改为 777 并使用 * com.android.chrome * 运行良好,但我上面的代码在尝试列出目录时返回 null
try {
Runtime.getRuntime().exec("su -c chmod 777 /data");
Runtime.getRuntime().exec("su -c chmod 777 /data/app");
Runtime.getRuntime().exec("su -c chmod 777 /data/app/*com.android.chrome*")
} catch (IOException e) { e.printStackTrace(); }
在没有 * 包 * 的情况下尝试过,但仍然为空 抱歉星星没有空格...因为文本编辑器识别为文本格式而进入空格
感谢之前
【问题讨论】:
-
所以我必须将 com.android.chrome-jAB96abq4RXcFrKebL0BUQ== 包含到路径中?
-
或者还有其他方法可以获取 com.android.chrome 中的文件夹列表吗?因为我确定每个设备都有不同的-extension :(
标签: android file root file-permissions