Skip to content

Instantly share code, notes, and snippets.

View dawidstrom's full-sized avatar
🏠
Working from home

David Ström dawidstrom

🏠
Working from home
View GitHub Profile
// 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.
*/