I have been creating mobile application using Android and Firebase, I can't get data from firebase, the problem is in the line Survey survey = ds.getValue(Survey.class);
, it work only when I delete attributes options and timestamp, Here is my code:
private FirebaseDatabase firebaseDatabase=FirebaseDatabase.getInstance();
private DatabaseReference mRootReference=firebaseDatabase.getReference();
private DatabaseReference mSurveysReference=mRootReference.child("surveys");
mSurveysReference.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
for (DataSnapshot ds:dataSnapshot.getChildren()){
Survey survey = ds.getValue(Survey.class);
surveys.add(survey);
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
});
public class Survey {
public boolean acceptAnonymousVotes;
public boolean enabled;
public String id;
public String image;
public Option[] options ;
public boolean resultPublic;
public Timestamp timeStamp;
public String title;
public int totalComments;
public int totalViews;
public int totalVotes;
public String type;
public String userId;
public Survey() {
}
}
public class Option {
public int id ;
public String title ;
}