首页 > 解决方案 > 获取内部文件android

问题描述

我有一个 java 文件,其中包含这段代码来列出应用程序缓存目录中的文件,它运行良好。

 String command[] = {"adb","shell","run-as",pack,"ls","cache/"};
 Process process = Runtime.getRuntime().exec(command);
 InputStream o_out = process.getInputStream(); //covert o_out to String to get the files name

现在我想让这段代码直接在android设备上运行,但它失败了,因为命令错误,知道吗?

标签: androidshell

解决方案


尝试这个:

String command[] = {"run-as",pack,"ls","cache/"};

推荐阅读