1

I want to delete some images from my phone. I have image path and I simply do this

try {
    File file = new File(content);
    if (file.canRead()) {
        boolean mDeleleFile = file.delete();
        sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(new File(content))));
        if (mDeleleFile) {
            Toast.makeText(getApplicationContext(), "File deleted", Toast.LENGTH_LONG).show();
        }
    }
} catch (Exception e) {
    e.printStackTrace();
}

Even if I get File deleted when I open gallery image still exist! Why is that? What I'm missing?

David
  • 3,055
  • 4
  • 30
  • 73

1 Answers1

0

your may have created a new file after deleting it.

Harrison Wu
  • 354
  • 2
  • 4