首页 > 代码库 > android 删除SD卡或者手机的缓存图片和目录

android 删除SD卡或者手机的缓存图片和目录

        public static final String TEMP_PHOTO_FILE_NAME = "temp_photo.jpg";
	private static String mSdRootPath = Environment.getExternalStorageDirectory().getPath();  
	  /** 
	     * 删除SD卡或者手机的缓存图片和目录 
	     */  
	    public void deleteFile() {  
	    	Log.i("INFO", mSdRootPath+"/"+TEMP_PHOTO_FILE_NAME+"========================");
	        File dirFile = new File(mSdRootPath+"/"+TEMP_PHOTO_FILE_NAME);  
	       if(! dirFile.exists()){  
	           return;  
	        }  
	        if (dirFile.isDirectory()) {  
	            String[] children = dirFile.list();  
	            for (int i = 0; i < children.length; i++) {  
	                new File(dirFile, children[i]).delete();  
	            }  
	        }  
	         
	        dirFile.delete();  
	   }