答案 0 :(得分:0)
如果uid/uuid
是您的 UserId ,则登录后您可以像这样使用:
FirebaseDatabase.getInstance().getReference().child("groups").child(FirebaseAuth.getInstance().getCurrentUser().getuid()).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
//Your data is here
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
答案 1 :(得分:0)
尝试一下
DatabaseReference mUsersDatabase;
//for getting groups data
mGroupsDatabase=FirebaseDatabase.getInstance().getReference().child("groups");
//add listener for getting uid or key
mUserDatabase.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot.exists())
{
dataSnapshot.getKey();
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
用于获取当前用户uid
private FirebaseAuth mAuth;
String mCurrentUserId;
mAuth = FirebaseAuth.getInstance();
mCurrentUserId = mAuth.getCurrentUser().getUid();
希望它对您有用!