Firebase join data in Android

后端 未结 1 400
小鲜肉
小鲜肉 2021-01-24 19:21

I\'m try to join three data using Firebase. I want to retrieve the the school name querying to classes data knowing only guard key which is g1

相关标签:
1条回答
  • 2021-01-24 19:58

    It might be too late but you would need to follow the documentation here.

    something like:

    var ref = new Firebase("https://myApp.firebaseio.com/");
    
        // fetch classes
        ref.child("classes").addChildEventListener(new ChildEventListener() {
          @Override
          public void onChildAdded(DataSnapshot snapshot, String previousChildKey) {
            //get school key 
            String schoolKey = snapshot.getKey();
    
            //get school name from key 
            ref.child("schools/" + schoolKey + "/name").addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot snapshot) {
                System.out.println("The school name is " + snapshot.getValue());
              }
    
              @Override
              public void onCancelled(FirebaseError firebaseError) {
                // ignore for now 
              }
            });
          }
        });
    
    0 讨论(0)
提交回复
热议问题