怎样读取系统文件

zhaohad 2012-09-23 11:34:23
我想在app层面读取系统中存在的所有文件,就像是root explorer一样,他是怎么申请root权限的?
...全文
113 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaohad 2012-09-23
  • 打赏
  • 举报
回复
追问:
难道root explorer不是在app层面上做的这种操作?
野生奥特曼x1 2012-09-23
  • 打赏
  • 举报
回复
root explorer怎么执行的我不知道 如果想要获得系统文件的话 要用到linux命令
public String exec() {
String folder = "";
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream dataOut = new DataOutputStream(process.getOutputStream());
InputStream dataIn = process.getInputStream();
dataOut.writeBytes("ls");
dataOut.flush();
if(dataIn.read() != 0) {
byte byteIn = (byte) dataIn.read();
int available = dataIn.available();
byte[] characters = new byte[available + 1];
characters[0] = byteIn;
dataIn.read(characters, 1, available);
folder = new String(characters);
}
return folder;
} catch (IOException e1) {
e1.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧