我的数据库中有这个结构:
user
- l5tCeZmcZtXLITJugdtfHsK647s1
email: "myemail@sample.com"
name: "Bob"
- userType
guestType: 1
- MyObject
Kke0cr5NUGEgg3rq_Mf: true // I can get the value true but I need to the key Kke0cr5NUGEgg3rq_Mf
如何只获取对象MyObject的id并将其放在变量中。
这是我试图做的事情:
DatabaseReference mDatabaseReference = FirebaseDatabase.getInstance().getReference().child(FirebaseUtil.USER).child(user.getUid());
mDatabaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String weedingCode = dataSnapshot.child("MyObject").getKey();
}