How can I get the value in Firebase Database with android?

前端 未结 2 1533
挽巷
挽巷 2021-01-23 12:15

My Firebase Realtime Database is like this :

{Singer :
    Billie Eilish :
        01 :
            songType : \"type01\"
            songName : \"bad guy\"
             


        
2条回答
  •  粉色の甜心
    2021-01-23 12:45

    why don't you just go with fetch data which contains only songType : type01 try this

    DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
    
    Query query = reference.child("Singer").orderByChild("songType").equalTo("type01");
    query.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if (dataSnapshot.exists()) {
                for (DataSnapshot issue : dataSnapshot.getChildren()) {
                    //set featched value to recyclerview 
                }
            }
        }
    
        @Override
        public void onCancelled(DatabaseError databaseError) {
    
        }
    });
    

提交回复
热议问题