Android Firebase getKey() returning child instead -


i have firebase database looks this:

appname:   chat:     [id]:       child1:value       child2:value 

i'm querying this:

databasereference ref = rootreference.child("chat").child([id]); ref.addlistenerforsinglevalueevent(new valueeventlistener() {   @override   public void ondatachange(datasnapshot datasnapshot) {     if (datasnapshot.exists()) {       long index = long.parselong(datasnapshot.getkey());     }   } 

the problem is, query doesn't work because datasnapshot.getkey() returns "child1" instead of id. same thing datasnapshot.getref().getkey(). if use datasnapshot.getref().getparent().getkey() "chat" back. how key datasnapshot? i'm extremely confused right now.

it turns out problem not in above code. further valueeventlistener made query , accidentally set listener this instead of myclass.this. valueeventlistener in this looking else, query incompatible.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -