I'm building this app in which I need to monitor a folder, when a file is modified (creatd, deleted, doesn´t matter) I have to notify the user. I have tried many ways and I can't reach the goal of running a notification because FileObserver is an abstract class.
It is important to notice that FileObserver is running trough a service, I'm monitoring plain texts that comes from another program that sychronices a folder with my app.
public class MyFileObserver extends FileObserver{
public String absolutePath;
public MyFileObserver(String path)
{
super(path, FileObserver.ALL_EVENTS);
absolutePath = path;
Log.v("","Now watching");
}
@Override
public void onEvent(int event, String path) {
if (path == null) {
return;
}
if ((FileObserver.CREATE & event)!=0)
{
FileAccessLogStatic.accessLogMsg +=absolutePath+"/"+path+"is created\n";
// Need to run a notification here
}
//here comes all the other methods
}
}