According to the documentation,
"Each FileObserver instance monitors a single file or directory. If a directory is monitored,
events will be triggered for all files and subdirectories inside the monitored directory."
My code goes like,
FileObserver fobsv = new FileObserver("/mnt/sdcard/") {
@Override
public void onEvent(int event, String path) {
System.out.println(event+" "+path);
}
};
fobsv.startWatching();
However, the onEvent()
is triggering only when a file is changed in the /mnt/sdcard/. If I create a file in /mnt/sdcard/downloads/, the method is not getting fired.
Is there any problem with the code?
According to the documentation
The documentation is incorrect, as is noted in this issue.
Is there any problem with the code?
No, but FileObserver
is not recursive, despite the documentation to the contrary.