How to delete a folder, such as /data/data/com.android.chrome/cache, if the phone has root rights?

Closed due to the fact that the question is too common for the participants Artem , 0xdb , Saidolim , Vadizar , Twiss Apr 8 '18 at 14:29 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • In what sense to delete? Programmatically or manually through the application? - Enikeyschik
  • programmatically, through your own created application, grant root the application rights and delete the folder - Enjo Flash
  • Only the user can give the application a root, the application itself cannot take it. If there are root-rights, then delete the same as any other regular folder. - Enikeyschik

1 answer 1

Getting "ROOT" rights for the Android application

"All you have to do is extend the class ExecuteAsRootBase and override the getCommandsToExecute method to return the commands you want to run as root."

How to programmatically delete files on Android?

try{ File file = new File("/data/data/com.android.chrome/cache"); if(file.delete()){ System.out.println(file.getName() + " is deleted!"); }else{ System.out.println("Delete operation is failed."); } }catch(Exception x){ System.out.println("Error. File not found."); }