Skip to content

Instantly share code, notes, and snippets.

@dawidstrom
Created March 28, 2018 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dawidstrom/cbc708753b7994f26c66c1ae5c7feb04 to your computer and use it in GitHub Desktop.
Save dawidstrom/cbc708753b7994f26c66c1ae5c7feb04 to your computer and use it in GitHub Desktop.
init
// 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.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment