Get notification of a file that is being deleted from SD card in Android

621 Views Asked by At

I am using FileObserver to get notification for deleted file.I want to save all deleted file from sd card(like Dumpster app) before deletion. But I get notification after the file has deleted but i want just before deletion so that I can save this file some where else that can be restored later just like dumpster android app( Dumpster ) . How to do this? I am using this code which gives me info about deleted file.

public void onEvent(int event, String path) {
    if (path == null) {
        return;
    }
    //a file was deleted from the monitored directory
    if ((FileObserver.DELETE & event)!=0) {
        //If Here I want to copy File some where else then I am getting 'File Not found exception'

}

}

0

There are 0 best solutions below