java - On Querying to firebase database datasnapshot retrives old value -


new value set firebase database (checked on firebase console) on query datasnapshot retrives old value.

final query query = firebasedatabase.getinstance().getreference(devices_table).orderbychild("deviceuniqueid").equalto(deviceuniqueid); query.addvalueeventlistener(new valueeventlistener() {     @override     public void ondatachange(datasnapshot datasnapshot) {         device device;         if (datasnapshot.getchildren().iterator().hasnext()) {             device = datasnapshot.getchildren().iterator().next().getvalue(device.class);             if (device.getisenable() == 1) {                 loginview.onerror(loginview.getcontext().getstring(r.string.error_device_disable));                 docyberoamlogout(musername, location);             } else {                 switch (mmessage) {                     case cyberoam_login_success_message:                         //login successful                         toast.maketext(activity, "cyberoam login success.", toast.length_short).show();                         new handler().postdelayed(new runnable() {                             @override                             public void run() {                                 getemailusingcyberoamid(musername, mpasswod);                             }                         }, 5000);                         break;                     case cyberoam_wrong_password:                         signoutfromfirebase();                         loginview.onerror(cyberoam_wrong_password);                         break;                     case cyberoam_max_login_limit:                         signoutfromfirebase();                         loginview.onerror(loginview.getcontext().getresources().getstring(r.string.prompt_max_login_limit));                         break;                     default:                         signoutfromfirebase();                         loginview.onerror(loginview.getcontext().getresources().getstring(r.string.action_cyberoam_login_failed));                         break;                 }             }             query.removeeventlistener(this);         }     }      @override     public void oncancelled(databaseerror databaseerror) {      }  }); 

you need remove line :

query.removeeventlistener(this); 

when persistence enabled addvalueeventlistener returns cached data first , next time new data.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -