json - Firebase returning null for Data values in Android -
all data.getvalue() returning null. can child key return fine. can write firbase fine. data.getvalue returning null unknown reason. have other classes working fine using exact same format.
//method retrieving info firebase has notifications private void retrieveinfo(){ firebase ref = new firebase("https://fitnectapp.firebaseio.com/"); // attach listener read data @ our posts reference ref.addchildeventlistener(new childeventlistener() { // retrieve new posts added database @override public void onchildadded(datasnapshot snapshot, string previouschildkey) { getupdates(snapshot); } @override public void onchildremoved(datasnapshot snapshot) { getupdates(snapshot); } @override public void onchildchanged(datasnapshot snapshot, string previouschildkey) { getupdates(snapshot); } @override public void onchildmoved(datasnapshot snapshot, string previouschildkey) { } @override public void oncancelled(firebaseerror firebaseerror) { } }); } //all data values returning null?? private void getupdates(datasnapshot ds) { if (ds.getkey().equals("notifications")) { (datasnapshot data : ds.getchildren()) { string user = sp.getstring("username", null); notification notification = data.getvalue(notification.class); if(notification.getnotifuser().equals(user)){ string sender = notification.getnotifsender(); string workout = notification.getnotifworkout(); string notificationtxt = sender + " has liked workout, " + workout; notifications.add(notificationtxt); } } } }
Comments
Post a Comment