I need to track removed images and videos from the whole file system all the time (even if my UI app is not running) so directly after startup of the handset until it's turned off. For this purpose I'm using a service and FileObserver. Unfortunately the code attached below doesn't work (I don't get with debugger to the method
public void onEvent(int event, String file)
although I made some changes to the FS... The Service gets started and obviously onStarted() method is executed...
please help
public class DataChangeListener extends Service {
private static Context context;
@Override
public IBinder onBind(Intent intent) {
context = this;
return null;
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
context = this;
FileObserver observer = new FileObserver("/") {
@Override
public void onEvent(int event, String file) {
System.out.println();
}
};
observer.startWatching();
}
@Override
public boolean onUnbind(Intent intent) {
return super.onUnbind(intent);
}
}