ChildEventListener

public interface ChildEventListener

Classes implementing this interface can be used to receive events about changes in the child locations of a given DatabaseReference ref. Attach the listener to a location using addChildEventListener(ChildEventListener) and the appropriate method will be triggered when changes occur.

Public Method Summary

abstract void
onCancelled(DatabaseError 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.
abstract void
onChildAdded(DataSnapshot snapshot, String previousChildName)
This method is triggered when a new child is added to the location to which this listener was added.
abstract void
onChildChanged(DataSnapshot snapshot, String previousChildName)
This method is triggered when the data at a child location has changed.
abstract void
onChildMoved(DataSnapshot snapshot, String previousChildName)
This method is triggered when a child location's priority changes.
abstract void
onChildRemoved(DataSnapshot snapshot)
This method is triggered when a child is removed from the location to which this listener was added.

Public Methods

public abstract void onCancelled (DatabaseError 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
error A description of the error that occurred

public abstract void onChildAdded (DataSnapshot snapshot, String previousChildName)

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

Parameters
snapshot An immutable snapshot of the data at the new child location
previousChildName The key name of sibling location ordered before the new child. This will be null for the first child node of a location.

public abstract void onChildChanged (DataSnapshot snapshot, String previousChildName)

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

Parameters
snapshot An immutable snapshot of the data at the new data at the child location
previousChildName The key name of sibling location ordered before the child. This will be null for the first child node of a location.

public abstract void onChildMoved (DataSnapshot snapshot, String previousChildName)

This method is triggered when a child location's priority changes. See setPriority(Object) and Ordered Data for more information on priorities and ordering data.

Parameters
snapshot An immutable snapshot of the data at the location that moved.
previousChildName The key name of the sibling location ordered before the child location. This will be null if this location is ordered first.

public abstract void onChildRemoved (DataSnapshot snapshot)

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

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

Send feedback about...

Need help? Visit our support page.