Java tutorial
//package com.java2s; import android.os.Environment; import android.text.TextUtils; import android.util.Log; import java.io.File; public class Main { public static boolean deleteSpicificFile(String filePath) { if (!isEmpty(filePath) && isSDCardAvailable()) { try { File file = new File(filePath); if (file.exists() && file.isFile()) { return file.delete(); } } catch (Exception e) { if (e != null && isNotEmpty(e.getMessage())) { Log.e("@@@", e.getMessage()); } } } return false; } public static boolean isEmpty(String text) { if (TextUtils.isEmpty(text)) { return true; } return false; } public static boolean isSDCardAvailable() { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { return true; } else { return false; } } public static boolean isNotEmpty(String text) { if (!TextUtils.isEmpty(text)) { return true; } return false; } }