# WatchEvent

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

# WatchEvent

`
public


interface
WatchEvent
`  
`


`

|-------------------------------|
| java.nio.file.WatchEvent\<T\> |

<br />

*** ** * ** ***

An event or a repeated event for an object that is registered with a[WatchService](https://developer.android.com/reference/java/nio/file/WatchService).

An event is classified by its[kind](https://developer.android.com/reference/java/nio/file/WatchEvent#kind())and has a[count](https://developer.android.com/reference/java/nio/file/WatchEvent#count())to indicate the number of times that the event has been observed. This allows for efficient representation of repeated events. The[context](https://developer.android.com/reference/java/nio/file/WatchEvent#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.

## Summary

|                                                                                                                                                            ### Nested classes                                                                                                                                                            ||
|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [WatchEvent.Kind](https://developer.android.com/reference/java/nio/file/WatchEvent.Kind)`<T>` An event kind, for the purposes of identification.                                                                                                                                                                           |
| ` interface` | [WatchEvent.Modifier](https://developer.android.com/reference/java/nio/file/WatchEvent.Modifier) An event modifier that qualifies how a[Watchable](https://developer.android.com/reference/java/nio/file/Watchable)is registered with a[WatchService](https://developer.android.com/reference/java/nio/file/WatchService). |

|                                                                                                        ### Public methods                                                                                                        ||
|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
| ` abstract T`                                                                                  | ` `[context](https://developer.android.com/reference/java/nio/file/WatchEvent#context())`() ` Returns the context for the event. |
| ` abstract int`                                                                                | ` `[count](https://developer.android.com/reference/java/nio/file/WatchEvent#count())`() ` Returns the event count.               |
| ` abstract `[Kind](https://developer.android.com/reference/java/nio/file/WatchEvent.Kind)`<T>` | ` `[kind](https://developer.android.com/reference/java/nio/file/WatchEvent#kind())`() ` Returns the event kind.                  |

## Public methods

### context

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract T context ()
```

Returns the context for the event.

In the case of[ENTRY_CREATE](https://developer.android.com/reference/java/nio/file/StandardWatchEventKinds#ENTRY_CREATE),[ENTRY_DELETE](https://developer.android.com/reference/java/nio/file/StandardWatchEventKinds#ENTRY_DELETE), and[ENTRY_MODIFY](https://developer.android.com/reference/java/nio/file/StandardWatchEventKinds#ENTRY_MODIFY)events the context is a`Path`that is the[relative](https://developer.android.com/reference/java/nio/file/Path#relativize(java.nio.file.Path))path between the directory registered with the watch service, and the entry that is created, deleted, or modified.

<br />

|                   Returns                   ||
|-----|----------------------------------------|
| `T` | the event context; may be`null` <br /> |

### count

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int count ()
```

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

<br />

|            Returns            ||
|-------|------------------------|
| `int` | the event count <br /> |

### kind

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Kind<T> kind ()
```

Returns the event kind.

<br />

|                                                  Returns                                                  ||
|------------------------------------------------------------------------------------|-----------------------|
| [Kind](https://developer.android.com/reference/java/nio/file/WatchEvent.Kind)`<T>` | the event kind <br /> |