Search code examples
androidfilesystemwatcher

Using android.os.FileObserver to watch "\data" directory not working


I set up a test program to learn more about FileObserver in android SDK (2.2). It seems to work fine when FileObserver is set up to watch "/mnt/sdcard". The onEvent() function gets called when some file system changes occur inside "/mnt/sdcard". However, if I change FileObserver to watch "/data", the onEvent() function no longer gets called even when I make file system changes in "/data".

Thanks in advance for any comments or answers.


Solution

  • You do not have read access to the whole of /data, so I am not surprised that FileObserver does not work for it.

    Try using FileObserver with a more narrow scope (e.g., your own getFilesDir()) to which you have read access.