In my Android app I want to detect events from directory. Here is code:
String path = Environment.getExternalStorageDirectory()
+ File.separator + "test2";
Log.d("test", "path is " + path);
FileObserver fileObserver = new FileObserver(path, FileObserver.ALL_EVENTS) {
@Override
public void onEvent(int event, String path) {
Log.d("test", "event dectect " + event + " " + path);
}
};
fileObserver.startWatching();
I copy new file to the directory. But I don't get any event. Please show me where I made a mistake.
adb shell
without minimizing Activity – Maryleemarylin