Search code examples
androidfilesystemslisten

listening for file changes in android file-system without file observer


I am still new to android programming, (wrote one small app so far) and I am also new to stack overflow. I am looking to write something that will listed for changes in a file, exactly like how file observer works. but the issue is the file im looking at receives changes from the kernel, and i realized that file observer does seem to pick up on changes unless it is done by the user. thanks.


Solution

  • I know this is old, but I figure I should Post the answer I found.

    The solution is UEventObserver

    doc: (http://www.androidjavadoc.com/1.1_r1_src/android/os/UEventObserver.html)

    I found my answer in the "frameworks / base / services / java / com / android / server /" area of the android source code where they listen to changes reported form the kernel.

    my implementation of the solution is here: https://github.com/gh123man/ICS_tablet_HW_rotationlock/blob/master/frameworks/base/services/java/com/android/server/RotationSwitchObserver.java