# Query

# Query


```
public class Query
```

<br />

Known direct subclasses [DatabaseReference](https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference)

|---|---|
| `https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference` | A Firebase reference represents a particular location in your Database and can be used for reading or writing data to that Database location. |

*** ** * ** ***

The Query class (and its subclass, `https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference`) are used for reading data. Listeners are attached, and they will be triggered when the corresponding data changes. Instances of Query are obtained by calling startAt(), endAt(), or limit() on a DatabaseReference.

## Summary

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ChildEventListener` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#addChildEventListener(com.google.firebase.database.ChildEventListener)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ChildEventListener listener)` Add a listener for child events occurring at this location. |
| `void` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#addListenerForSingleValueEvent(com.google.firebase.database.ValueEventListener)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ValueEventListener listener)` Add a listener for a single change in the data at this location. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ValueEventListener` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#addValueEventListener(com.google.firebase.database.ValueEventListener)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ValueEventListener listener)` Add a listener for changes in the data at this location. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#endAt(java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#endAt(double)(double value)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#endAt(boolean)(boolean value)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#endAt(java.lang.String,java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than or equal to the given key. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#endAt(double,java.lang.String)(double value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than or equal to the given key. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#endAt(boolean,java.lang.String)(boolean value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than or equal to the given key. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#endBefore(java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value)` Creates a query constrained to only return child nodes with a value less than the given value, using the given `orderBy` directive or priority as default. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#endBefore(double)(double value)` Creates a query constrained to only return child nodes with a value less than the given value, using the given `orderBy` directive or priority as default. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#endBefore(boolean)(boolean value)` Creates a query constrained to only return child nodes with a value less than the given value, using the given `orderBy` directive or priority as default. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#endBefore(java.lang.String,java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than the given key. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#endBefore(double,java.lang.String)(double value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than the given key. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#endBefore(boolean,java.lang.String)(boolean value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than the given key. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#equalTo(java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value)` Creates a query constrained to only return child nodes with the given value. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#equalTo(double)(double value)` Creates a query constrained to only return child nodes with the given value. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#equalTo(boolean)(boolean value)` Creates a query constrained to only return child nodes with the given value. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#equalTo(java.lang.String,java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return the child node with the given key and value. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#equalTo(double,java.lang.String)(double value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return the child node with the given key and value. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#equalTo(boolean,java.lang.String)(boolean value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return the child node with the given key and value. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<https://firebase.google.com/docs/reference/android/com/google/firebase/database/DataSnapshot>` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#get()()` Gets the server values for this query. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#getRef()()` |
| `void` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#keepSynced(boolean)(boolean keepSynced)` By calling \`keepSynced(true)\` on a location, the data for that location will automatically be downloaded and kept in sync, even when no listeners are attached for that location. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#limitToFirst(int)(int limit)` Creates a query with limit and anchor it to the start of the window. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#limitToLast(int)(int limit)` Creates a query with limit and anchor it to the end of the window. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#orderByChild(java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html path)` Creates a query in which child nodes are ordered by the values of the specified path. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#orderByKey()()` Creates a query in which child nodes are ordered by their keys. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#orderByPriority()()` Creates a query in which child nodes are ordered by their priorities. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#orderByValue()()` Creates a query in which nodes are ordered by their value |
| `void` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#removeEventListener(com.google.firebase.database.ChildEventListener)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ChildEventListener listener)` Remove the specified listener from this location. |
| `void` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#removeEventListener(com.google.firebase.database.ValueEventListener)(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ValueEventListener listener)` Remove the specified listener from this location. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#startAfter(java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value)` Creates a query constrained to only return child nodes with a value greater than the given value, using the given `orderBy` directive or priority as default. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#startAfter(double)(double value)` Creates a query constrained to only return child nodes with a value greater than the given value, using the given `orderBy` directive or priority as default. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#startAfter(boolean)(boolean value)` Creates a query constrained to only return child nodes with a value greater than the given value, using the given `orderBy` directive or priority as default. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#startAfter(java.lang.String,java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return child nodes with a value greater or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than the given key. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#startAfter(double,java.lang.String)(double value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than the given key. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#startAfter(boolean,java.lang.String)(boolean value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than the given key. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#startAt(java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#startAt(double)(double value)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#startAt(boolean)(boolean value)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#startAt(java.lang.String,java.lang.String)(@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than or equal to the given key. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#startAt(double,java.lang.String)(double value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than or equal to the given key. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#startAt(boolean,java.lang.String)(boolean value, @https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than or equal to the given key. |

| ### Extension functions |
|---|---|
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ChildEvent>` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseKt.https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#(com.google.firebase.database.Query).getChildEvents()(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query receiver)` |
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/DataSnapshot>` | `https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseKt.https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#(com.google.firebase.database.Query).getSnapshots()(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query receiver)` |
| `final @https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<T>` | `<T extends https://developer.android.com/reference/kotlin/java/lang/Object.html> https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseKt.https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query#(com.google.firebase.database.Query).values()(@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query receiver)` Starts listening to this query and emits its values converted to a POJO via a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`. |

## Public methods

### addChildEventListener

```
public @NonNull ChildEventListener addChildEventListener(@NonNull ChildEventListener listener)
```

Add a listener for child events occurring at this location. When child locations are added, removed, changed, or moved, the listener will be triggered for the appropriate event

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ChildEventListener listener` | The listener to be called with changes |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ChildEventListener` | A reference to the listener provided. Save this to remove the listener later. |

### addListenerForSingleValueEvent

```
public void addListenerForSingleValueEvent(@NonNull ValueEventListener listener)
```

Add a listener for a single change in the data at this location. This listener will be triggered once with the value of the data at the location.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ValueEventListener listener` | The listener to be called with the data |

### addValueEventListener

```
public @NonNull ValueEventListener addValueEventListener(@NonNull ValueEventListener listener)
```

Add a listener for changes in the data at this location. Each time the data changes, your listener will be called with an immutable snapshot of the data.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ValueEventListener listener` | The listener to be called with changes |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ValueEventListener` | A reference to the listener provided. Save this to remove the listener later. |

### endAt

```
public @NonNull Query endAt(@Nullable String value)
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value` | The value to end at, inclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### endAt

```
public @NonNull Query endAt(double value)
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default.

| Parameters |
|---|---|
| `double value` | The value to end at, inclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### endAt

```
public @NonNull Query endAt(boolean value)
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default.

2.0

| Parameters |
|---|---|
| `boolean value` | The value to end at, inclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### endAt

```
public @NonNull Query endAt(@Nullable String value, @Nullable String key)
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than or equal to the given key.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value` | The value to end at, inclusive |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key to end at, inclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### endAt

```
public @NonNull Query endAt(double value, @Nullable String key)
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than or equal to the given key.

| Parameters |
|---|---|
| `double value` | The value to end at, inclusive |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key to end at, inclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### endAt

```
public @NonNull Query endAt(boolean value, @Nullable String key)
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than or equal to the given key.

2.0

| Parameters |
|---|---|
| `boolean value` | The value to end at, inclusive |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key to end at, inclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### endBefore

```
public @NonNull Query endBefore(@Nullable String value)
```

Creates a query constrained to only return child nodes with a value less than the given value, using the given `orderBy` directive or priority as default.

19.6

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value` | The value to end at, exclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### endBefore

```
public @NonNull Query endBefore(double value)
```

Creates a query constrained to only return child nodes with a value less than the given value, using the given `orderBy` directive or priority as default.

19.6

| Parameters |
|---|---|
| `double value` | The value to end at, exclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### endBefore

```
public @NonNull Query endBefore(boolean value)
```

Creates a query constrained to only return child nodes with a value less than the given value, using the given `orderBy` directive or priority as default.

19.6

| Parameters |
|---|---|
| `boolean value` | The value to end at, exclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### endBefore

```
public @NonNull Query endBefore(@Nullable String value, @Nullable String key)
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than the given key.

19.6

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value` | The value to end at |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key to end at, exclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### endBefore

```
public @NonNull Query endBefore(double value, @Nullable String key)
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than the given key.

19.6

| Parameters |
|---|---|
| `double value` | The value to end at |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key to end at, exclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### endBefore

```
public @NonNull Query endBefore(boolean value, @Nullable String key)
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than the given key.

19.6

| Parameters |
|---|---|
| `boolean value` | The value to end at |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key to end at, exclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### equalTo

```
public @NonNull Query equalTo(@Nullable String value)
```

Creates a query constrained to only return child nodes with the given value.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value` | The value to query for |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### equalTo

```
public @NonNull Query equalTo(double value)
```

Creates a query constrained to only return child nodes with the given value.

| Parameters |
|---|---|
| `double value` | The value to query for |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### equalTo

```
public @NonNull Query equalTo(boolean value)
```

Creates a query constrained to only return child nodes with the given value.

2.0

| Parameters |
|---|---|
| `boolean value` | The value to query for |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### equalTo

```
public @NonNull Query equalTo(@Nullable String value, @Nullable String key)
```

Creates a query constrained to only return the child node with the given key and value. Note that there is at most one such child as names are unique.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value` | The value to query for |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key of the child |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### equalTo

```
public @NonNull Query equalTo(double value, @Nullable String key)
```

Creates a query constrained to only return the child node with the given key and value. Note that there is at most one such child as keys are unique.

| Parameters |
|---|---|
| `double value` | The value to query for |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key of the child |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### equalTo

```
public @NonNull Query equalTo(boolean value, @Nullable String key)
```

Creates a query constrained to only return the child node with the given key and value. Note that there is at most one such child as keys are unique.

| Parameters |
|---|---|
| `boolean value` | The value to query for |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The name of the child |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### get

```
public @NonNull Task<DataSnapshot> get()
```

Gets the server values for this query. Updates the cache and raises events if successful. If not connected, falls back to a locally-cached value.

### getRef

```
public @NonNull DatabaseReference getRef()
```

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference` | A DatabaseReference to this location |

### keepSynced

```
public void keepSynced(boolean keepSynced)
```

By calling \`keepSynced(true)\` on a location, the data for that location will automatically be downloaded and kept in sync, even when no listeners are attached for that location. Additionally, while a location is kept synced, it will not be evicted from the persistent disk cache.

2.3

| Parameters |
|---|---|
| `boolean keepSynced` | Pass \`true\` to keep this location synchronized, pass \`false\` to stop synchronization. |

### limitToFirst

```
public @NonNull Query limitToFirst(int limit)
```

Creates a query with limit and anchor it to the start of the window.

2.0

| Parameters |
|---|---|
| `int limit` | The maximum number of child nodes to return |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### limitToLast

```
public @NonNull Query limitToLast(int limit)
```

Creates a query with limit and anchor it to the end of the window.

2.0

| Parameters |
|---|---|
| `int limit` | The maximum number of child nodes to return |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### orderByChild

```
public @NonNull Query orderByChild(@NonNull String path)
```

Creates a query in which child nodes are ordered by the values of the specified path.

2.0

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://developer.android.com/reference/kotlin/java/lang/String.html path` | The path to the child node to use for sorting |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### orderByKey

```
public @NonNull Query orderByKey()
```

Creates a query in which child nodes are ordered by their keys.

2.0

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### orderByPriority

```
public @NonNull Query orderByPriority()
```

Creates a query in which child nodes are ordered by their priorities.

2.0

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### orderByValue

```
public @NonNull Query orderByValue()
```

Creates a query in which nodes are ordered by their value

2.2

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### removeEventListener

```
public void removeEventListener(@NonNull ChildEventListener listener)
```

Remove the specified listener from this location.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ChildEventListener listener` | The listener to remove |

### removeEventListener

```
public void removeEventListener(@NonNull ValueEventListener listener)
```

Remove the specified listener from this location.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/ValueEventListener listener` | The listener to remove |

### startAfter

```
public @NonNull Query startAfter(@Nullable String value)
```

Creates a query constrained to only return child nodes with a value greater than the given value, using the given `orderBy` directive or priority as default.

19.6

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value` | The value to start at, exclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### startAfter

```
public @NonNull Query startAfter(double value)
```

Creates a query constrained to only return child nodes with a value greater than the given value, using the given `orderBy` directive or priority as default.

19.6

| Parameters |
|---|---|
| `double value` | The value to start at, exclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### startAfter

```
public @NonNull Query startAfter(boolean value)
```

Creates a query constrained to only return child nodes with a value greater than the given value, using the given `orderBy` directive or priority as default.

19.6

| Parameters |
|---|---|
| `boolean value` | The value to start at, exclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### startAfter

```
public @NonNull Query startAfter(@Nullable String value, @Nullable String key)
```

Creates a query constrained to only return child nodes with a value greater or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than the given key.

19.6

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value` | The value to start at |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key to start at, exclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### startAfter

```
public @NonNull Query startAfter(double value, @Nullable String key)
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than the given key.

19.6

| Parameters |
|---|---|
| `double value` | The value to start at |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key name to start at, exclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### startAfter

```
public @NonNull Query startAfter(boolean value, @Nullable String key)
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than the given key.

19.6

| Parameters |
|---|---|
| `boolean value` | The value to start at |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key to start at, exclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### startAt

```
public @NonNull Query startAt(@Nullable String value)
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value` | The value to start at, inclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### startAt

```
public @NonNull Query startAt(double value)
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default.

| Parameters |
|---|---|
| `double value` | The value to start at, inclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### startAt

```
public @NonNull Query startAt(boolean value)
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default.

2.0

| Parameters |
|---|---|
| `boolean value` | The value to start at, inclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### startAt

```
public @NonNull Query startAt(@Nullable String value, @Nullable String key)
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than or equal to the given key.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html value` | The priority to start at, inclusive |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key to start at, inclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### startAt

```
public @NonNull Query startAt(double value, @Nullable String key)
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than or equal to the given key.

| Parameters |
|---|---|
| `double value` | The priority to start at, inclusive |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key name to start at, inclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

### startAt

```
public @NonNull Query startAt(boolean value, @Nullable String key)
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than or equal to the given key.

2.0

| Parameters |
|---|---|
| `boolean value` | The priority to start at, inclusive |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Nullable.html https://developer.android.com/reference/kotlin/java/lang/String.html key` | The key to start at, inclusive |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query` | A query with the new constraint |

## Extension functions

### DatabaseKt.getChildEvents

```
public final @NonNull Flow<@NonNull ChildEvent> DatabaseKt.getChildEvents(@NonNull Query receiver)
```

### DatabaseKt.getSnapshots

```
public final @NonNull Flow<@NonNull DataSnapshot> DatabaseKt.getSnapshots(@NonNull Query receiver)
```

### DatabaseKt.values

```
public final @NonNull Flow<T> <T extends Object> DatabaseKt.values(@NonNull Query receiver)
```

Starts listening to this query and emits its values converted to a POJO via a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`.

- When the returned flow starts being collected, a `https://firebase.google.com/docs/reference/android/com/google/firebase/database/ValueEventListener` will be attached.

- When the flow completes, the listener will be removed.