Android Guides | Samples

Android.OS.FileObserver Class

Monitors files (using ) to fire an event after files are accessed or changed by by any process on the device (including this one).

See Also: FileObserver

Syntax

[Android.Runtime.Register("android/os/FileObserver", DoNotGenerateAcw=true)]
public abstract class FileObserver : Object

Remarks

Monitors files (using ) to fire an event after files are accessed or changed by by any process on the device (including this one). FileObserver is an abstract class; subclasses must implement the event handler FileObserver.OnEvent(FileObserverEvents,String).

Each FileObserver instance monitors a single file or directory. If a directory is monitored, events will be triggered for all files and subdirectories inside the monitored directory.

An event mask is used to specify which changes or actions to report. Event type constants are used to describe the possible changes in the event mask as well as what actually happened in event callbacks.

Warning: If a FileObserver is garbage collected, it will stop sending events. To ensure you keep receiving events, you must keep a reference to the FileObserver instance from some other live object.

[Android Documentation]

Requirements

Namespace: Android.OS
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.OS.FileObserver are listed below.

See Also: Object

Public Constructors

Equivalent to FileObserver(path, FileObserver.
Create a new file observer for a certain file or directory.

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

abstract
OnEvent(FileObserverEvents, String)
The event handler, which must be implemented by subclasses.
StartWatching()
Start watching for events.
StopWatching()
Stop watching for events.