Created
November 2, 2010 02:25
-
-
Save shirou/659181 to your computer and use it in GitHub Desktop.
Detect File Change using FileObserver on Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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