ChildEventListener

public interfaceChildEventListener


Classes implementing this interface can be used to receive events about changes in the child locations of a givenDatabaseReference ref. Attach the listener to a location usingaddChildEventListener and the appropriate method will be triggered when changes occur.

Summary

Public methods

abstract void

This method will be triggered in the event that this listener either failed at the server, or is removed as a result of the security and Firebase rules.

abstract void
onChildAdded(
    @NonNullDataSnapshot snapshot,
    @NullableString previousChildName
)

This method is triggered when a new child is added to the location to which this listener was added.

abstract void
onChildChanged(
    @NonNullDataSnapshot snapshot,
    @NullableString previousChildName
)

This method is triggered when the data at a child location has changed.

abstract void
onChildMoved(
    @NonNullDataSnapshot snapshot,
    @NullableString previousChildName
)

This method is triggered when a child location's priority changes.

abstract void

This method is triggered when a child is removed from the location to which this listener was added.

Public methods

onCancelled

abstract void onCancelled(@NonNullDatabaseError error)

This method will be triggered in the event that this listener either failed at the server, or is removed as a result of the security and Firebase rules. For more information on securing your data, see: Security Quickstart

Parameters
@NonNullDatabaseError error

A description of the error that occurred

onChildAdded

abstract void onChildAdded(
    @NonNullDataSnapshot snapshot,
    @NullableString previousChildName
)

This method is triggered when a new child is added to the location to which this listener was added.

Parameters
@NonNullDataSnapshot snapshot

An immutable snapshot of the data at the new child location

@NullableString previousChildName

The key name of sibling location ordered before the new child. This will be null for the first child node of a location.

onChildChanged

abstract void onChildChanged(
    @NonNullDataSnapshot snapshot,
    @NullableString previousChildName
)

This method is triggered when the data at a child location has changed.

Parameters
@NonNullDataSnapshot snapshot

An immutable snapshot of the data at the new data at the child location

@NullableString previousChildName

The key name of sibling location ordered before the child. This will be null for the first child node of a location.

onChildMoved

abstract void onChildMoved(
    @NonNullDataSnapshot snapshot,
    @NullableString previousChildName
)

This method is triggered when a child location's priority changes. SeesetPriority andOrdered Data for more information on priorities and ordering data.

Parameters
@NonNullDataSnapshot snapshot

An immutable snapshot of the data at the location that moved.

@NullableString previousChildName

The key name of the sibling location ordered before the child location. This will be null if this location is ordered first.

onChildRemoved

abstract void onChildRemoved(@NonNullDataSnapshot snapshot)

This method is triggered when a child is removed from the location to which this listener was added.

Parameters
@NonNullDataSnapshot snapshot

An immutable snapshot of the data at the child that was removed.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-21 UTC.