sudo sudo - 1 year ago 512
Android Question

Retrieve Firebase Data saved with push()

I have a Firebase database.When im saving data i used the

to generate auto increment key.

now my db like this

name: "Sri Lankan"

When im retrieving data i got this error

W/ClassMapper: No setter/field for -KJxz53rLIc4rZPVjK48 found on class com.kosala.uyamu2.Data_Category

This my

public class Data_Category {

String name;

public Data_Category() {}
public Data_Category(String name) { = name;}
public String getName() {
return name;}
public void setName(String name) { = name;}}

This is where i retrieving data

mDatabase.child("recipe").child("Categories").addListenerForSingleValueEvent(new ValueEventListener() {
public void onDataChange(DataSnapshot dataSnapshot) {
Data_Category data = dataSnapshot.getValue(Data_Category.class);
Log.d("name", data.getName());

public void onCancelled(DatabaseError databaseError) {


Can any one help me here.Thanks.

Answer Source


 public void onDataChange(DataSnapshot dataSnapshot) {
       for (DataSnapshot data : dataSnapshot.getChildren()) 
                     Data_Category category = data.getValue(Data_Category.class);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download