Class AndroidSharedFileObserver

java.lang.Object
FileObserver
com.mku.android.file.AndroidSharedFileObserver

public class AndroidSharedFileObserver extends FileObserver
Implementation of a file observer that detects when a share file has been edited by external apps. Use this to get notified to re-import the file into the drive.
  • Method Details

    • createFileObserver

      public static AndroidSharedFileObserver createFileObserver(File cacheFile, SalmonFile salmonFile, Consumer<AndroidSharedFileObserver> onFileContentsChanged)
      Create a file observer that will detect if the file contents of a shared salmon file have changed
      Parameters:
      cacheFile - The temporary private decrypted cached file
      salmonFile - The encrypted file that is associated with the shared file
      onFileContentsChanged - Action notifier when file contents change
      Returns:
      The shared file observer
    • removeFileObserver

      public static void removeFileObserver(File cacheFile)
      Remove the shared filed associated with this observer.
      Parameters:
      cacheFile - The cache file.
    • clearFileObservers

      public static void clearFileObservers()
      Clear all file observers. Call this to release any observes you no longer need.
    • onEvent

      public void onEvent(int e, String path)
      When a file event happens.
      Parameters:
      e - The type of event which happened
      path - The path, relative to the main monitored file or directory, of the file or directory which triggered the event. This value can be null for certain events, such as #MOVE_SELF.
    • getSalmonFile

      public SalmonFile getSalmonFile()
      Returns the encrypted salmon file that is associated with the shared file
      Returns:
      The file
    • setSalmonFile

      public void setSalmonFile(SalmonFile salmonFile)
      Set the salmon file associated with the shared file to observer.
      Parameters:
      salmonFile - The file