答案 0 :(得分:5)
试试这个:
DatabaseReference reference = FirebaseDatabase.getInstance().getReference("inspirational");
reference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot datas: dataSnapshot.getChildren()){
String keys=datas.getKey();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
首先,您需要转到dataSnapshot inspirational
,然后在其中进行迭代,这将为您提供随机密钥String keys=datas.getKey();