Skip to content

Most visited

Recently visited

added in API level 26


public interface WatchEvent


An event or a repeated event for an object that is registered with a WatchService.

An event is classified by its kind and has a count to indicate the number of times that the event has been observed. This allows for efficient representation of repeated events. The context method returns any context associated with the event. In the case of a repeated event then the context is the same for all events.

Watch events are immutable and safe for use by multiple concurrent threads.


Nested classes

interface WatchEvent.Kind<T>

An event kind, for the purposes of identification. 

interface WatchEvent.Modifier

An event modifier that qualifies how a Watchable is registered with a WatchService

Public methods

abstract T context()

Returns the context for the event.

abstract int count()

Returns the event count.

abstract Kind<T> kind()

Returns the event kind.

Public methods


added in API level 26
T context ()

Returns the context for the event.

In the case of ENTRY_CREATE, ENTRY_DELETE, and ENTRY_MODIFY events the context is a Path that is the relative path between the directory registered with the watch service, and the entry that is created, deleted, or modified.

T the event context; may be null


added in API level 26
int count ()

Returns the event count. If the event count is greater than 1 then this is a repeated event.

int the event count


added in API level 26
Kind<T> kind ()

Returns the event kind.

Kind<T> the event kind

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)