I want to develop an application in blackberry that is running in background and should listen for change in particular folder i.e. whether the file in particular folder/directory has been added or removed.
I can achive that using FileSystemJournalListener, but my problem is that it listen or invoke every time when the file is added or removed every time in “ANY DIRECTORY/FOLDER”. But i don’t want that behavior, i only need some way or any other listener that listen for any change of files in a particular directory.
Thanks in advance.
I am agree with pajton’s comment, we should use FileSystemJournalListener there and just skip useless events.
With proper filtering it shouldn’t cause any performance issue – this kind of functionality is exactly what this class is for. Why don’t extand FileSystemJournalListener into some DirectoryListener with filtering by directories implemented and to FileListener with filtering for files?
We can cache latest viewed events retrieved from FileSystemJournal.getNextUSN() in each listener (and of course, clear cache on filter change), so it will look only for the new file system events.
And don’t forget to use treads there to loop over events – so app will continue execution without troubles.