I use this code to delete all files:
File root = new File(\"root path\"); File[] Files = root.listFiles(); if(Files != null) { int j; for(j = 0; j < F
As a kotlin extension function you can do this
fun File.deleteDirectoryFiles(){ this.listFiles().forEach { if(it.isDirectory){ it.deleteDirectoryFiles() }else{ it.delete() } } this.delete() }
Then you can just do
file.deleteDirectoryFiles()