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 and the appropriate method will be triggered when changes occur.
Summary
Public methods |
|
|---|---|
abstract void |
onCancelled(@NonNull 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(This method is triggered when a new child is added to the location to which this listener was added. |
abstract void |
onChildChanged(This method is triggered when the data at a child location has changed. |
abstract void |
onChildMoved(This method is triggered when a child location's priority changes. |
abstract void |
onChildRemoved(@NonNull DataSnapshot snapshot)This method is triggered when a child is removed from the location to which this listener was added. |
Public methods
onCancelled
abstract void onCancelled(@NonNull 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 | |
|---|---|
@NonNull DatabaseError error |
A description of the error that occurred |
onChildAdded
abstract void onChildAdded(
@NonNull DataSnapshot snapshot,
@Nullable String previousChildName
)
This method is triggered when a new child is added to the location to which this listener was added.
| Parameters | |
|---|---|
@NonNull DataSnapshot snapshot |
An immutable snapshot of the data at the new child location |
@Nullable String 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(
@NonNull DataSnapshot snapshot,
@Nullable String previousChildName
)
This method is triggered when the data at a child location has changed.
| Parameters | |
|---|---|
@NonNull DataSnapshot snapshot |
An immutable snapshot of the data at the new data at the child location |
@Nullable String 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(
@NonNull DataSnapshot snapshot,
@Nullable String previousChildName
)
This method is triggered when a child location's priority changes. See setPriority and Ordered Data for more information on priorities and ordering data.
| Parameters | |
|---|---|
@NonNull DataSnapshot snapshot |
An immutable snapshot of the data at the location that moved. |
@Nullable String 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(@NonNull DataSnapshot snapshot)
This method is triggered when a child is removed from the location to which this listener was added.
| Parameters | |
|---|---|
@NonNull DataSnapshot snapshot |
An immutable snapshot of the data at the child that was removed. |