Android File Remove removeFile(String absPath)

Here you can find the source of removeFile(String absPath)

Description

Xoa 1 file khoi he thong

Parameter

Parameter Description
absPath a parameter

Declaration

public static Boolean removeFile(String absPath) 

Method Source Code

//package com.java2s;
import java.io.File;

public class Main {
    /**//  w w w.  j  av  a  2 s  .  c  o m
     * Xoa 1 file khoi he thong
     * 
     * @param absPath
     * @return
     */
    public static Boolean removeFile(String absPath) {
        if (absPath == null || absPath.equals("")) {
            return false;
        }
        File f = new File(absPath);
        if (f.isFile()) {
            return f.delete();
        }
        return false;
    }

    /**
     * Delete File or Folder recursively
     * 
     * @param root
     * @return
     */
    public static Boolean delete(String root) {
        if (root == null) {
            return false;
        }
        File f = new File(root);
        if (f.isDirectory()) {
            for (File tmp : f.listFiles()) {
                delete(tmp.getAbsolutePath());
            }
        }
        return f.delete();
    }
}

Related

  1. remove(File file)
  2. remove(String filePath)
  3. deleteAllFiles(Vector filesToDelete)