这是我的代码
private final static String Dir = "/data/data/org.xbmc.kodi/cache/";
private void deleteDir(){
try{
/*File dir = Utils.getCacheDir(null, this, false, true);
File path = new File(dir.getParentFile(), Dir);
delete(path);*/
String command = "rm -r "+Dir;
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes(command + "\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
}catch(Exception e){}
}
Run Code Online (Sandbox Code Playgroud)
问题是当我运行它时它会删除该文件夹。但我不想删除该文件夹。我想删除里面的所有文件。