SoFunction
Updated on 2025-04-04

How to delete Android build files

This article introduces Android to delete all build compiled files, translate disk space, share it with everyone, and leave a note for yourself, as follows:

 public static void main(String[] args) {
   //Pause into a directory.   deleteFileWithThread("D:\\");

/**
 * Multiple threads are opened here to improve efficiency
 **/
private static void deleteFileWithThread(String path) {
   File file = new File(path);
   if (()) {
     File[] files = ();
     int length = ;
     for (File outFile : files) {
       if (()) {
         File[] filesIn = ();
         if (filesIn != null) {
           int lengthIn = ;
           for (int i = 0; i < lengthIn; i++) {
             int a = i;
             new Thread() {
               @Override
               public void run() {
                 delDir(filesIn[a]);
               }
             }.start();
           }
         }
       }
     }
   }
 }
 }

//Use recursive method to delete folderspublic static void delDir(File f) {
   // Determine whether it is a directory. If it is not, skip it and delete it directly; if it is a directory, clear its contents first.   if (()) {
     File[] rootFile = ();
     for (File file : rootFile) {
       if (()) {
         if ("build".equals(())) { //Delete all contents in the folder and folder of the build           ("fileName delete\t" + () + "\t" + ());
           delete(file);
           ();
         } else {
           delDir(file);

         }
       }
     }
   }
 }

Through the above code, you can delete the contents of all build folders under the Android project.

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.