Java tutorial
//package com.java2s; import java.io.File; import android.content.ContentResolver; import android.content.Context; import android.net.Uri; import android.provider.MediaStore; public class Main { public static void deletFiles(File delFile, Context mContext) { // TODO Auto-generated method stub if (delFile == null) { return; } if (delFile.exists()) { if (delFile.isFile()) { delFile.delete(); deleteFileForMediaStore(mContext, delFile); } } } private static void deleteFileForMediaStore(Context mContext, File file) { // Match on the file path String selection = MediaStore.Images.Media.DATA + " = ?"; String[] selectionArgs = new String[] { file.getAbsolutePath() }; // Query for the ID of the media matching the file path Uri queryUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; ContentResolver contentResolver = mContext.getContentResolver(); contentResolver.delete(queryUri, selection, selectionArgs); } }