/** * 删除文件夹 * * String 文件夹路径及名称 如/sdcard/data/ * String * @return boolean */ public static void delFolder(String folderPath) { try { delAllFile(folderPath); // 删除完里面所有内容 String filePath = folderPath; filePath = filePath.toString(); File myFilePath = new File(filePath); myFilePath.delete(); // 删除空文件夹 } catch (Exception e) { System.out.println("删除文件夹操作出错"); e.printStackTrace(); } }
public static String getRandomImageFilePath() { return getPublicFilePath(TYPE_IMAGE); }
/** * Create a file for saving an image or video,is default in the * ../Pictures/[you app PackageName] directory * * @param context * @param type the type of the file you want saved {@link #MEDIA_TYPE_IMAGE} * {@link #MEDIA_TYPE_VIDEO} * @return return the file you create,if create failed,return null */ private static File getOutputMediaFile(Context context, int type) { String filePath = null; if (type == MEDIA_TYPE_IMAGE) { filePath = FileUtil.getRandomImageFilePath(); } else if (type == MEDIA_TYPE_VIDEO) { //filePath = FileUtil.getRandomVideoFilePath(); } else { return null; } if (TextUtils.isEmpty(filePath)) { return null; } else { return new File(filePath); } }
delAllFile(path + "/" + tempList[i]); // 先删除文件夹里面的文件 delFolder(path + "/" + tempList[i]); // 再删除空文件夹
if (CameraManager.mNewPhotoUri != null) { CameraManager.mCurrentFile = new File(CameraManager.mNewPhotoUri.getPath()); CameraManager.mlocitionFileUrl = FileUtil.getRealFilePath(context, CameraManager.mNewPhotoUri);
if (CameraManager.mNewPhotoUri != null) { CameraManager.mCurrentFile = new File(CameraManager.mNewPhotoUri.getPath()); CameraManager.mlocitionFileUrl = FileUtil.getRealFilePath(context, CameraManager.mNewPhotoUri);