If your phone is rooted, you can issue commands with root privileges via su - provided that there is a su binary file and your PATH - since Android is a Linux variant. Just execute the delete commands with Runtime.exec() , and Superuser should take care of the permission prompt.
Here is a simple example of its use. I took from this question :
process = Runtime.getRuntime().exec("su"); os = new DataOutputStream(process.getOutputStream()); os.writeBytes(command + "\n"); os.writeBytes("exit\n"); os.flush(); process.waitFor();
source share