我正在检索 id 下的许多值,但它不起作用。这应该很容易,但我被卡住了。
这是我的数据结构:
Attendance
x73aXTQHXHXHQ
current
value: "Bill Gates"
company
value: "Apple"
history
-La7wew7hdxccdcdzssf
value: 156000000001
-La7wptthd3ceeqoz34f
value: 156000000002
-La7wew7hdxccdcdzssf
value: 156000000003
我已经尝试过这段代码,并且只成功检索了 children count ,而不是我想要的Output: 3children 值。156000000001这是我的代码,任何帮助谢谢。
if (uid != null) {
ref.child(uidKeys).child(uid).child("history").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
int countUnderHistory = (int) dataSnapshot.getChildrenCount();
long[] dataHistory = new long[countUnderHistory];
int index = 0;
for (DataSnapshot push : dataSnapshot.getChildren()) {
NonDuplicateAttendance nDa = push.getValue(NonDuplicateAttendance.class);
if (nDa != null) {
dataHistory[index] = nDa.getuHistory();
}
index++;
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
NonDuplicateAttendance类:
package com.example.aspireone.myapplication;
public class NonDuplicateAttendance {
private long value;
public NonDuplicateAttendance(long value) {
this.value = value;
}
public long getuHistory() {
return value;
}
}
慕雪6442864
Cats萌萌
随时随地看视频慕课网APP
相关分类