public void exeShell(String cmd){
try{
Process p = Runtime.getRuntime().exec(cmd);
BufferedReader in = new BufferedReader(
new InputStreamReader(
p.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
Log.i("exeShell",line);
}
}
catch(Throwable t)
{
t.printStackTrace();
}
}
注意,不支持流重定位符和通配符,如不支持: “rm /data/*” 或"echo 8 > /proc/kernel/printk"
不能用通配符,那删除目录下的所有文件怎么办?
rm -r /data/