简体   繁体   中英

How to display username and email from firebase in android

i am trying to get username and email for single user profile.

在此处输入图片说明

I think that firebaseAuth.getCurrentUser().getUid() return uid that is not the same as uid in FirebaseDatabase. You can user Query.

For example:

Query q = firebaseDatabase.child("users").orderByChild("email").equalTo(firebaseAuth.getCurrentUser().getEmail());

You should use addChildEventListener instead of addValueEventListener , and write the code inside onChildAdded .

You can find the explanation fromdocumentation :

When working with lists, your application should listen for child events rather than the value events used for single objects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM