code: public static boolean deleteDirectory(final File dir) {
  		boolean success = true;
  		if (dir != null && dir.exists()) {
  			try {
  				if (dir.isDirectory()) {
  					for (final File file : dir.listFiles()) {
  						if(file == null) {
  							return false;
  						}
  						if (!deleteDirectory(file)) {
  							success = false;
  							return success;
  						}
  					}
  				}
  				if (!dir.delete()) {
  					success = false;
  					return success;
  				}
  				return success;
  			} catch (Exception e) {
  				// Failed to delete files or directory
  			}
  		}
  		return false;
  	}
docs: Deletes a directory recursively.
  
  @param dir  Directory to delete.
  @return     True if the delete was successful.