Ich habe mobile Anwendung mit Android und Firebase erstellt, kann ich keine Daten von Firebase, das Problem ist in der Zeile Survey survey = ds.getValue(Survey.class);
, funktioniert es nur, wenn ich Attribute Optionen und Zeitstempel, hier löschen mein Code:So rufen Sie Daten aus Firebase-Datenbank
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 ;
}
Was ist der Fehler? Haben Sie verwandte Fragen überprüft? wie diese https://stackoverflow.com/questions/38462259/how-to-retrieve-the-data-firebase-3-0-database?rq=1 –