Process process = null;
DataOutputStream os = null;
try {String command = "chmod 777 " + "data";
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(command + "\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
} catch (Exception e) {
} finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
}
}
这样可以访问data文件夹
DataOutputStream os = null;
try {String command = "chmod 777 " + "data";
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(command + "\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
} catch (Exception e) {
} finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
}
}
这样可以访问data文件夹
String[] command={"su","-c","/data"}
Process=Runtime.getRuntime().exec(command);
process.waitfor();
os = new DataOutputStream(process.getOutputStream());不知道这样行不行了~