This file contains 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
// File recides in external public storage /Documents/file.txt, I've checked this is the actual file being looked at. | |
filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath()+"/file.txt"; | |
// Have tried CREATE and CLOSE_WRITE, none of them triggers when I transfer file.txt to Documents using MTP transfer on windows machine. | |
MyObserver observer = new MyObserver(filePath, FileObserver.CREATE, this); | |
observer.startWatching3(); | |
/* This works correctly if the file exists. | |
if (new File(file).exists()) | |
observer.onEvent(1, "") // Dummy values. | |
*/ |