List of usage examples for java.io File delete
public boolean delete()
From source file:Main.java
public static boolean renameFile(String src, String dst) { File srcFile = new File(src); File dstFile = new File(dst); if (dstFile.exists()) { dstFile.delete(); }/*from ww w . j a v a 2 s .c o m*/ return srcFile.renameTo(dstFile); }
From source file:Main.java
/** * Method to delete saved user image when sign out * * @param path the saved image path// w w w .jav a 2 s . co m * @return the boolean to indicate if the photo is deleted or not */ public static boolean deleteUserImageFromStorage(String path) { if (path != null) { File file = new File(path); return file.delete(); } else { return false; } }
From source file:Main.java
public static void DeleteRecursive(File fileOrDirectory) { boolean bool; if (fileOrDirectory.isDirectory()) for (File child : fileOrDirectory.listFiles()) { bool = child.delete(); System.out.println(" deleted folder contents > result : " + bool); DeleteRecursive(child);/*from w w w.jav a2 s . c o m*/ } bool = fileOrDirectory.delete(); System.out.println(" deleted folder > result : " + bool); }
From source file:Main.java
public static boolean deleteDownloadFile(String path) { File file = new File(path); if (file.exists()) { return file.delete(); }/*from w w w. ja v a2s . c om*/ return true; }
From source file:Main.java
/** * Remove an album from the cache./*from w w w . j a v a 2s.c o m*/ * @param albumId Album ID */ public static void removeAlbum(String albumId) { File albumDir = new File(getMusicCacheDir(), albumId); if (albumDir.exists()) { for (File file : albumDir.listFiles()) { file.delete(); } albumDir.delete(); } }
From source file:Main.java
public static void deleteFile(String filePath) { if (filePath == null || "".equals(filePath)) { return;//w ww .ja v a 2s. c o m } File file = new File(filePath); if (file.exists()) { file.delete(); } }
From source file:Utils.java
/** * Creates a new empty temporary directory. *///from www. ja va2 s .co m public static File createTmpDir() throws IOException { // create a temporary directory File tmpFile = File.createTempFile("tmp", "tmp", new File(".")); tmpFile.delete(); tmpFile.mkdir(); return tmpFile; }
From source file:Main.java
public static boolean hasSDCard(Context context) { if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) { String dir = Environment.getExternalStorageDirectory() + FILE_DIR; File f = new File(dir); if (!f.exists()) { f.mkdir();/*from w w w .jav a 2s .c om*/ } else { try { for (File t : f.listFiles()) { t.delete(); } } catch (Exception e) { e.printStackTrace(); } } return true; } return false; }
From source file:Main.java
public static boolean deleteFile(String path) { File file = new File(path); if (file.exists()) { return file.delete(); }/*from w w w. ja va 2 s .c om*/ return false; }
From source file:Main.java
public static void storeImage(Bitmap bitmap, String outPath) throws FileNotFoundException { File file = new File(outPath); if (file.exists()) { file.delete(); }/*from www . j ava 2 s . com*/ FileOutputStream os = new FileOutputStream(outPath); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, os); }