[英]Query in Firebase database child
I'm new to android. Can someone help me to query the below-underlined line in the firebase?我是android的新手,谁能帮我查询一下firebase下面划线的那一行? The query result should be the underlined String.查询结果应该是带下划线的字符串。
That String is an autogenerated one in the firebase at the Driver signup.该字符串是驱动程序注册时 firebase 中自动生成的字符串。 So hardcoding that string is not my aim.所以硬编码那个字符串不是我的目标。
Refer to Users/Driver
and loop through children, you will get your key:请参阅Users/Driver
并遍历子项,您将获得密钥:
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference().child("Users").child("Driver");
ValueEventListener listener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//loop through the children
for(DataSnapshot ds: dataSnapshot.getChildren()){
//get the key or keys depending on how many keys
String underLinedKey = ds.getKey();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
//log error
Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
}
};
mDatabase.addValueEventListener(listener);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.