android - How to get only the updated child data from firebase database? -


i able fetch child node firebase database.

 firebase firebase = new firebase("https://myfiebase-url.firebaseio.com/");     firebase.addvalueeventlistener(new com.firebase.client.valueeventlistener() {         @override         public void ondatachange(com.firebase.client.datasnapshot datasnapshot) {             system.out.println(datasnapshot.getvalue());             log.e("testing message", datasnapshot.getvalue() + "--->")             }           @override         public void oncancelled(firebaseerror firebaseerror) {          } 

enter image description here

but problem when new data add inside node example if 1 more data added inside node 2. @ time ondatachange() return complete data. want retrieve updated data.

now getting response:

e/testing message: [null, {-krbu6cm_ip7xwqhcyot={date=10-08-2017, stared=, chatid=, time=thu aug 10 21:39:32 gmt+05:30 2017, message=gagsgs, userid=0, timestamp=}, -krxiybouqez7btzf9jw={date=15-08-2017, stared=, chatid=, time=tue aug 15 03:20:38 ist 2017, message=fggffg, userid=0, timestamp=}, -kquvlhuja1pz-how-xf={date=07-08-2017, stared=, chatid=, time=mon aug 07 09:53:35 gmt+05:30 2017, message=xvxcggg, userid=0, timestamp=}, -krxb8scq3blrzt3hzux={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:48:20 gmt+05:30 2017, message=tggggg, userid=0, timestamp=}, -krxatbjgvt8hlzetahn={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:47:13 gmt+05:30 2017, message=gggfy, userid=0, timestamp=}, -krxazinl9_zeambve_1={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:45:46 gmt+05:30 2017, message=shubhank, userid=0, timestamp=}, -krxbbgehja3cmlhlttx={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:48:31 gmt+05:30 2017, message=tyyggg, userid=0, timestamp=}, -krxfvrqlvw8oxpozjlw={date=15-08-2017, stared=, chatid=, time=tue aug 15 03:07:22 gmt+05:30 2017, message=fggh, userid=0, timestamp=}, -krxav5zkbz369g4n2_n={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:45:28 gmt+05:30 2017, message=gghhu, userid=0, timestamp=}, -krxb2rzgm98jiu8dz7i={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:47:55 gmt+05:30 2017, message=ytttt, userid=0, timestamp=}, -krxb1mkp1pir5pekcgp={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:47:49 gmt+05:30 2017, message=ttttt, userid=0, timestamp=}, -krxacx7z-inoynla6zb={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:46:03 gmt+05:30 2017, message=eeqdss, userid=0, timestamp=}, -krxagbxxvn5dx1ykpbd={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:46:20 gmt+05:30 2017, message=mn mm, userid=0, timestamp=}, -krxcbnyuqo8ia7wroo1={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:54:43 ist 2017, message=bdhdhdd, userid=0, timestamp=}, -krxczlha5rvjcedpai6={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:54:30 ist 2017, message=xdff, userid=0, timestamp=}, -krxagsuq2ilmjvhbnoi={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:46:21 gmt+05:30 2017, message=lp, userid=0, timestamp=}, -krxhz1xewxygudnt8yv={date=15-08-2017, stared=, chatid=, time=tue aug 15 03:18:10 gmt+05:30 2017, message=fhfdt, userid=0, timestamp=}, -krxanjdsh9ipqcjcut0={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:46:47 gmt+05:30 2017, message=ghjhh, userid=0, timestamp=}, -krxb-jzqlwoebuswppw={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:47:42 gmt+05:30 2017, message=dfgffg, userid=0, timestamp=}, -krxehxow-jb5n0luw5s={date=15-08-2017, stared=, chatid=, time=tue aug 15 03:02:03 ist 2017, message=ftffft, userid=0, timestamp=}, -krxcv2og5ineetdacmj={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:54:13 ist 2017, message=gfggg, userid=0, timestamp=}, -krxb6zfyp5dnaexkmmu={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:48:12 gmt+05:30 2017, message=tttt, userid=0, timestamp=}, -krxc4bhhwzsqfbvj8hu={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:52:25 ist 2017, message=vhhhh, userid=0, timestamp=}, -kquvqzmkh3enenizhhr={date=07-08-2017, stared=, chatid=, time=mon aug 07 09:53:59 gmt+05:30 2017, message=gdgsggdd, userid=0, timestamp=}, -krxayjvxlc3hxqsivnf={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:47:32 gmt+05:30 2017, message=frsddr, userid=0, timestamp=}, -kqqdbq5ui8ij-jg5kn2={date=06-08-2017, stared=, chatid=, time=sun aug 06 13:53:59 gmt+05:30 2017, message=gfggg, userid=0, timestamp=}}, {-krxsl1ksbbqf38mhxtb={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:07:18 gmt+05:30 2017, message=gggg, userid=0, timestamp=}, -krx6yitdwgibf4sr2mj={date=15-08-2017, stared=, chatid=, time=tue aug 15 00:32:08 gmt+05:30 2017, message=gggg, userid=0, timestamp=}, -krxtekqpj1sz7qukgrp={date=15-08-2017, stared=, chatid=, time=tue aug 15 02:09:23 gmt+05:30 2017, message=cffg, userid=0, timestamp=}}, {-krxlo1inf4-0hewrvd7={date=15-08-2017, stared=, chatid=, time=tue aug 15 01:35:05 gmt+05:30 2017, message=aastha, userid=0, times 

if want told specific child node has been modified, should use firebase's childeventlistener:

firebase.addchildeventlistener(new com.firebase.client.childeventlistener() {     @override     public void onchildadded(com.firebase.client.datasnapshot datasnapshot, string previouschildkey) {         log.i("onchildadded", "child "+datasnapshot.getkey()+" added after "+previouschildkey)     }      @override     public void onchildremoved(com.firebase.client.datasnapshot datasnapshot) {         log.i("onchildremoved", "child "+datasnapshot.getkey()+" removed")     }     ... 

the onchild* methods tell happened: onchildadded, onchildremoved, onchildchanged , onchildmoved.

btw: you're using firebase sdk @ least year , half old , hasn't been updated since. highly* recommend switch on new version of firebase sdk. if you're looking convert existing code, @ upgrade guide.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

Why does math.random(999999999999) returns 1 in Lua? -