I need to monitor all files in a folder, when a file opened (FileObserver.OPEN) I want to execute a method. The problem is some times, the FileObserver instance is collected by GC, I tried this:
final MyFileObserver fo = new MyFileObserver("/mnt/sdcard/Musicas");
threadFileObserver = new Runnable() {
@Override
public void run() {
fo.startWatching();
}
};
t = new Thread(threadFileObserver);
t.run();
But is being collected. The question is, what is the best solution for a instance of FileObserver not be collected?
tks!!!