FileObserver is called twice

I am using FileObserver to view a folder in android. When a user modifies or creates a new file in this folder, FileObserver has to do some things with that file.

The thing is, using the FileObserver.MODIFY clause, every time I create / modify a file in this watched folder, the FileObserver onEvent () method is called twice. This is a problem for me because it destroys everything I do afterwards (this is done twice).

This is my code:

mFileObserver = new FileObserver(directoryPath, FileObserver.MODIFY){
        public void onEvent(int event, String fileName){
            if (event == FileObserver.MODIFY){
                // some stuff to do
            }
        }
    }; 

      

+3


source to share





All Articles