Ir para o console

DataSnapshot

public class DataSnapshot extends Object

A DataSnapshot instance contains data from a Firebase Database location. Any time you read Database data, you receive the data as a DataSnapshot.

DataSnapshots are passed to the methods in listeners that you attach with addValueEventListener(ValueEventListener), addChildEventListener(ChildEventListener), or addListenerForSingleValueEvent(ValueEventListener).

They are efficiently-generated immutable copies of the data at a Firebase Database location. They can't be modified and will never change. To modify data at a location, use a DatabaseReference reference (e.g. with setValue(Object)).

Public Method Summary

DataSnapshot
child(String path)
Get a DataSnapshot for the location at the specified relative path.
boolean
exists()
Returns true if the snapshot contains a non-null value.
Iterable<DataSnapshot>
getChildren()
Gives access to all of the immediate children of this snapshot.
long
String
Object
getPriority()
Returns the priority of the data contained in this snapshot as a native type.
DatabaseReference
getRef()
Used to obtain a reference to the source location for this snapshot.
Object
getValue(boolean useExportFormat)
getValue() returns the data contained in this snapshot as native types.
<T> T
getValue(GenericTypeIndicator<T> t)
Due to the way that Java implements generics, it takes an extra step to get back a properly-typed Collection.
Object
getValue()
getValue() returns the data contained in this snapshot as native types.
<T> T
getValue(Class<T> valueType)
This method is used to marshall the data contained in this snapshot into a class of your choosing.
boolean
hasChild(String path)
Can be used to determine if this DataSnapshot has data at a particular location
boolean
hasChildren()
Indicates whether this snapshot has any children
String

Inherited Method Summary

Public Methods

public DataSnapshot child (String path)

Get a DataSnapshot for the location at the specified relative path. The relative path can either be a simple child key (e.g. 'fred') or a deeper slash-separated path (e.g. 'fred/name/first'). If the child location has no data, an empty DataSnapshot is returned.

Parameters
path A relative path to the location of child data
Returns
  • The DataSnapshot for the child location

public boolean exists ()

Returns true if the snapshot contains a non-null value.

Returns
  • True if the snapshot contains a non-null value, otherwise false

public Iterable<DataSnapshot> getChildren ()

Gives access to all of the immediate children of this snapshot. Can be used in native for loops:
for (DataSnapshot child : parent.getChildren()) {
    ...
}

Returns
  • The immediate children of this snapshot

public long getChildrenCount ()

Returns
  • The number of immediate children in the this snapshot

public String getKey ()

Returns
  • The key name for the source location of this snapshot or null if this snapshot points to the database root.

public Object getPriority ()

Also: