delete a single file - Android java.io

Android examples for java.io:File Delete

Description

delete a single file

Demo Code

import java.io.File;

import android.util.Log;

public class Main {

  private static final String TAG = "";

  public static boolean delete(File file) {
    if (file != null && file.exists()) {
      if (!file.delete()) {
        Log.w(TAG, "Failed to delete file " + file);
        return false;
      }/*from  ww w. ja  v a2s  . c  om*/
      Log.i(TAG, "Deleted file " + file);
    }
    return true;
  }

}

Related Tutorials