问题描述
我想从这种类型的JSON树中获取允许的子级:
$ b $ FirebaseDatabase database = FirebaseDatabase.getInstance(); FirebaseDatabase.getInstance(); FirebaseDatabase.getInstance(); FirebaseDatabase.getInstance(); FirebaseDatabase.getInstance();
DatabaseReference userRef = database.getReference(users)。child(key).child(Alloweded);
ValueEventListener postListener = new ValueEventListener(){
@Override $ b $ public void onDataChange(DataSnapshot dataSnapshot){
User userObj = dataSnapshot.getValue(User.class);
$ @覆盖
public void onCancelled(DatabaseError databaseError){
//获取发布失败,记录消息
Log。 w(TAG,loadPost:onCancelled,databaseError.toException());
// ...
}
}; userRef.addValueEventListener(postListener);
试试这个我希望它能正常工作。
I want to get Allowed child from this type of JSON Tree:
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference userRef = database.getReference("users").child(key).child("Alloweded");
ValueEventListener postListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
User userObj = dataSnapshot.getValue(User.class);
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Getting Post failed, log a message
Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
// ...
}
};userRef.addValueEventListener(postListener);
Try this I hope it works fine.
这篇关于如何使用Android从Firebase数据库嵌套Child?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!