com.google.firebase.database

Interfaces

ChildEventListener

Classes implementing this interface can be used to receive events about changes in the child locations of a given DatabaseReference ref.

DatabaseReference.CompletionListener

This interface is used as a method of being notified when an operation has been acknowledged by the Database servers and can be considered complete

Logger

This interface is used to setup logging for Realtime Database.

Transaction.Handler

An object implementing this interface is used to run a transaction, and will be notified of the results of the transaction.

ValueEventListener

Classes implementing this interface can be used to receive events about data changes at a location.

Classes

ChildEvent

Used to emit events about changes in the child locations of a given Query when using the childEvents Flow.

ChildEvent.Added

Emitted when a new child is added to the location.

ChildEvent.Changed

Emitted when the data at a child location has changed.

ChildEvent.Moved

Emitted when a child location's priority changes.

ChildEvent.Removed

Emitted when a child is removed from the location.

DataSnapshot

A DataSnapshot instance contains data from a Firebase Database location.

DatabaseError

Instances of DatabaseError are passed to callbacks when an operation failed.

DatabaseReference

A Firebase reference represents a particular location in your Database and can be used for reading or writing data to that Database location.

FirebaseDatabase

The entry point for accessing a Firebase Database.

GenericTypeIndicator

Due to the way that Java implements generics (type-erasure), it is necessary to use a slightly more complicated method to properly resolve types for generic collections at runtime.

MutableData

Instances of this class encapsulate the data and priority at a location.

OnDisconnect

The OnDisconnect class is used to manage operations that will be run on the server when this client disconnects.

Query

The Query class (and its subclass, DatabaseReference) are used for reading data.

ServerValue

Contains placeholder values to use when writing data to the Firebase Database.

Transaction

The Transaction class encapsulates the functionality needed to perform a transaction on the data at a location.

Transaction.Result

Instances of this class represent the desired outcome of a single run of a Handler's doTransaction method.

Exceptions

DatabaseException

This error is thrown when the Firebase Database library is unable to operate on the input it has been given.

Annotations

Exclude

Marks a field as excluded from the Database.

IgnoreExtraProperties

Properties that don't map to class fields are ignored when serializing to a class annotated with this annotation.

PropertyName

Marks a field to be renamed when serialized.

ThrowOnExtraProperties

Properties that don't map to class fields when serializing to a class annotated with this annotation cause an exception to be thrown.

Enums

Logger.Level

The log levels used by the Realtime Database library

Extension functions summary

FirebaseDatabase

Returns the FirebaseDatabase instance of the given FirebaseApp and url.

FirebaseDatabase

Returns the FirebaseDatabase instance of the given FirebaseApp.

FirebaseDatabase

Returns the FirebaseDatabase instance for the specified url.

inline T?

Returns the content of the DataSnapshot converted to a POJO.

inline T?

Returns the content of the MutableData converted to a POJO.

inline Flow<T?>
<T : Any> Query.values()

Starts listening to this query and emits its values converted to a POJO via a Flow.

Extension properties summary

Flow<ChildEvent>

Starts listening to this query's child events and emits its values via a Flow.

FirebaseDatabase

Returns the FirebaseDatabase instance of the default FirebaseApp.

Flow<DataSnapshot>

Starts listening to this query and emits its values via a Flow.

Extension functions

database

fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase

Returns the FirebaseDatabase instance of the given FirebaseApp and url.

database

fun Firebase.database(app: FirebaseApp): FirebaseDatabase

Returns the FirebaseDatabase instance of the given FirebaseApp.

database

fun Firebase.database(url: String): FirebaseDatabase

Returns the FirebaseDatabase instance for the specified url.

getValue

inline fun <T : Any?> DataSnapshot.getValue(): T?

Returns the content of the DataSnapshot converted to a POJO.

Supports generics like List<> or Map<>. Use @JvmSuppressWildcards to force the compiler to use the type T, and not ? extends T.

getValue

inline fun <T : Any?> MutableData.getValue(): T?

Returns the content of the MutableData converted to a POJO.

Supports generics like List<> or Map<>. Use @JvmSuppressWildcards to force the compiler to use the type T, and not ? extends T.

values

inline fun <T : Any> Query.values(): Flow<T?>

Starts listening to this query and emits its values converted to a POJO via a Flow.

  • When the returned flow starts being collected, a ValueEventListener will be attached.

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

Extension properties

childEvents

val Query.childEventsFlow<ChildEvent>

Starts listening to this query's child events and emits its values via a Flow.

  • When the returned flow starts being collected, a ChildEventListener will be attached.

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

database

val Firebase.databaseFirebaseDatabase

Returns the FirebaseDatabase instance of the default FirebaseApp.

snapshots

val Query.snapshotsFlow<DataSnapshot>

Starts listening to this query and emits its values via a Flow.

  • When the returned flow starts being collected, a ValueEventListener will be attached.

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