Skip to content

Instantly share code, notes, and snippets.

@shirou
Created November 2, 2010 02:25
Show Gist options
  • Save shirou/659181 to your computer and use it in GitHub Desktop.
Save shirou/659181 to your computer and use it in GitHub Desktop.
Detect File Change using FileObserver on Android
FileObserver f;
f = createWatchList("/sdcard/");
f.startWatching();
watchList.add(f);
f = createWatchList("/sdcard/tmp");
f.startWatching();
watchList.add(f);
}
private FileObserver createWatchList(String path){
File file = new File(path);
if (file == null || ! file.isDirectory()){
Log.d(TAG, "path is not directory.");
return null;
}
return new PathFileObserver(path);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment