Android 文件及文件夹删除

 
  
public static void delete(File file){
    try{
        if(file.exists()){
            if(file.isFile()){
                file.delete();
            }else if(file.isDirectory()){
                File files[] = file.listFiles();
                for(int i=0;ilength;i++){
                    files[i].delete();
                }
            }
            file.delete();
        }else{
	    Log.i("Tag","所删除的文件不存在!"+'\n');
        }
    }
    catch(Exception e){
	Log.i("Tag","unable to delete the folder!");
}}

你可能感兴趣的:(Android)