title: Why does FileObserver only work in /sdcard/data/[package_name]?
body: <p>I am trying to monitor all files operations(create, read, write, modify, delete) in ‘/sdcard’ directory. It seems the class FileObserver could do the job from the documentation”<a href="https://developer.android.com/reference/android/os/FileObserver.html" rel="nofollow noreferrer">https://developer.android.com/reference/android/os/FileObserver.html</a>”. Iimplement onEvent method like this,</p>
  
  <pre><code> @Override
      public void onEvent(int event, @Nullable String path) {
          Log.d("sdevent",""+event);
          switch(event) {
              case FileObserver.ALL_EVENTS:
                  Log.d("sdcardlistener", "path:"+ path);
                  break;
              case FileObserver.CREATE:
                  Log.d("sdcardlistener", "path:"+ path);
                  break;
          }
      }
  </code></pre>
  
  <p>But when I try it on my Android studio 3.5.3 using emulator Pixel2(API 28) and my own phone which is Android Q now, I cannot get any event on path ‘/sdcard’ or its subdirectory ,‘/sdcard/DCIM’ for example. The code is like this.</p>
  
  <pre><code>SDCardListener listener1=new SDCardListener("/sdcard");
  listener1.startWatching();
  </code></pre>
  
  <p>If I change the path to a app-specific one, like ‘/sdcard/Android/data/com.example.myfiletest(my app name)/files/apple’, it seems to work for the directory and its fist subdirectory.</p>
  
  <pre><code>SDCardListener listener2=new SDCardListener("/sdcard/Android/data/com.example.myfiletest/files/apple");
  listener2.startWatching();
  </code></pre>
  
  <p>Since this situation doesn’t match documentation, I want to know where is the problem. And is there a way to monitor all file changes in externel storage if FileObserver not capable to do so. </p>