android - Why am I not getting value of child value from Firebase? -


i want value of uid firebase database, looks that:

enter image description here

and below code value

 mpostkey=getintent().getextras().getstring("profile_id");     mdatabase= firebasedatabase.getinstance().getreference().child("profiles").child(mpostkey).child("uid");     mdatabase.addlistenerforsinglevalueevent(new valueeventlistener() {         @override         public void ondatachange(datasnapshot datasnapshot) {              muid=datasnapshot.getvalue().tostring();         }          @override         public void oncancelled(databaseerror databaseerror) {          }     }); 

and debugger showing these values

enter image description here

i'm pointing uid correctly i'm unable value, keep on getting null in muid.

you need change line of code:

muid=datasnapshot.getvalue().tostring(); 

with

string muid=datasnapshot.getvalue(string.class); 

add line of code after above declaration verify if works:

log.d("tag", muid); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -