Android 具有根权限的listfiles()不工作
我的应用程序访问root以查看应用程序数据,但它不工作。Android 具有根权限的listfiles()不工作,android,Android,我的应用程序访问root以查看应用程序数据,但它不工作。 我试过这个: private File[] appDataList() { Runtime.getRuntime().exec("su"); File directories = new File("/data/data"); return directories.listFiles(); } 但它不工作,lisFiles()为空,内容不可见,请求根访问 注意:在根设备上测试。1)手机可能是非根设备。您可以检查以
我试过这个:
private File[] appDataList() {
Runtime.getRuntime().exec("su");
File directories = new File("/data/data");
return directories.listFiles();
}
但它不工作,lisFiles()为空,内容不可见,请求根访问
注意:在根设备上测试。1)手机可能是非根设备。您可以检查以下内容:
> adb shell
> su
2) 检查答案。请求root权限不会授予应用程序root权限,只需创建一个具有root权限的新进程:
· 如果要获取
/data/data
中的文件列表,请使用ls
命令
if (RootTools.isAccessGiven()) {
Command myCommand = new Command(0, "ls /data/data") {
@Override
public void commandOutput(int i, String line) {
//line = File/Folder name (not includes the complete path)
//Do your stuff here using line variable
}
@Override
public void commandTerminated(int i, String s) {
}
@Override
public void commandCompleted(int i, int i1) {
}
};
RootTools.getShell(true).add(myCommand);
}