FileObserver does not work. Android 4.4.3

Updated link 5-4.4.3.

Fileobserver does not work for any directory. I tried 1./data/data/com/whatsapp, 2.sdcard / Movies, and also 3. "/". Before the update, it worked fine.

I saw RecursiveFileObserver on github and used it along with a file server. When both are used together, the onEvent of my FileObserver is called, which is rather strange. After a while, ANR appears.

So how to use fileobserver in android 4.4.3

Here is my code

FileObserver observer = new FileObserver("/data/data/com.whatsapp/databases") {  
     public void onEvent(int event, String file) {
         Log.i("ASH", "path VSLLED");
       Log.i("ASH", "path AXCCESSED     " + file);
      }
    };
    observer.startWatching();

and link for RecursiveFileObserver    https://github.com/bartoszprzybylski/owncloud-android/blob/master/src/com/owncloud/android/utils/RecursiveFileObserver.java

Btw, FileObserver runs on a service

+4
2

FileObserver KitKat -android.permission.WRITE_EXTERNAL_STORAGE. , 4.4 Android, , , , . , .

+3

FileObserver . , , context.getDir/getFilesDir. .

0

Source: https://habr.com/ru/post/1544327/


All Articles