code: public static boolean deleteDirContents(final File dir) {
          if (dir.isDirectory()) {
              final String[] children = dir.list();
              for (final String aChildren : children) {
                  final File child = new File(dir, aChildren);
                  if (child.isDirectory()) {
                      // Delete the sub directories
                      if (!deleteDir(child)) {
                          return false;
                      }
                  } else {
                      // Delete a single file in the directory
                      if (!child.delete()) {
                          return false;
                      }
                  }
              }
          }
          return true;
      }
docs: Delete the contents of a directory and all of its sub directories/files
  
  @param dir The directory whose content is to be deleted.
  @return True if the directories contents were deleted otherwise false if an error occurred.