Click here to Skip to main content
15,939,808 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello, I'm trying to implement Recycle Bin application in android, I came across FileObserver class to observe all the files, but the problem is FileObserver only notifies that file is deleted after file deletion, here is my code snippet

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

    }
}


Please any body share your knowledge to solve this riddle. This kind of Recycle Bin question been asked so many times here and in other sites too, but no proper solutions yet.

There is an application in Google Play and the name of that application is Dumpster which is achieving the task.

Please help me.

Thanks in advance.
Posted
Updated 12-Sep-13 20:27pm
v2

1 solution

Some days ago I answered similar question.

Take a look - Explain about logger in android[^]. It might help you.
 
Share this answer
 
Comments
cschethan03 13-Sep-13 2:56am    
It's not very helpful @Tadit Dash, but can you please share your knowledge about this riddle ? Thanks for your time Tadit Dash
I was just searching answers for that question and found that.

Why it was not useful for you? It is saying that you can't get it done by FileObserver, there is no such events what you want. You have to follow some other way to do that.
cschethan03 13-Sep-13 4:13am    
I'm trying to find that other way from past 1 week, but no success so far, if you know any other way please do share.
Can you do something before the event onEvent?
cschethan03 13-Sep-13 5:05am    
Nope I can't do any thing before onEvent @Tradit Dash

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900