【发布时间】:2013-06-16 01:39:09
【问题描述】:
我只是想写一个应用程序来访问超级用户访问并了解它的工作原理。
所以我正在使用以下方法将一些文本写入文件:
public void update(View v){
Process p;
try{
// Preform su to get root privledges
p = Runtime.getRuntime().exec("su");
// Attempt to write a file to a root-only
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("echo \"Do I have root?\" >/system/etc/temporary.txt\n");
// Close the terminal
os.writeBytes("exit\n");
os.flush();
try{
p.waitFor();
if(p.exitValue() != 225){
showToast("ROOTED !");
} else {
showToast("not root");
}
} catch(InterruptedException e){
showToast("not root");
}
} catch(IOException e){
showToast("not root");
}
}
因此,当我调用此方法时,将显示敬酒 ROOTED !。意味着文件temporary.txt 必须在我手机的/system/etc 文件夹中创建。但是当我使用 Root Explorer 应用程序浏览到该文件夹时,我什么也看不到。
这件事让我很困惑,因为显示了ROOTED ! toast,但我看不到文件。
是的,我的手机已经root了。
【问题讨论】: