[Java]/*** get the folder size * @ param file File instance * @ return long in the unit of M * @ throws Exception */public static long getFolderSize (java. io. file file) throws Exception {long size = 0; java. io. file [] fileList = file. listFiles (); for (int I = 0; I <fileList. length; I ++) {if (fileList [I]. isDirectory () {size = size + getFolderSize (fileList [I]);} else {size = size + fileList [I]. length () ;}} return size/1048576;} [Java]/*** delete files and directories in the specified directory ** @ param deleteThisPath * @ param filepath * @ return */public void deleteFolderFile (String filePath, boolean deleteThisPath) throws IOException {if (! TextUtils. isEmpty (filePath) {File file = new File (filePath); if (file. isDirectory () {// process directory File files [] = file. listFiles (); for (int I = 0; I <files. length; I ++) {deleteFolderFile (files [I]. getAbsolutePath (), true);} www.2cto.com} if (deleteThisPath) {if (! File. isDirectory () {// if it is a file, delete the file. delete ();} else {// directory if (file. listFiles (). length = 0) {// No file or directory exists in the directory. delete the file. delete ();}}}}}