android - Having trouble on firebase fetching data and display in Textview......, -


i have been working on code several days,first thought database reference has problem,getref working,so little bit confused because datasnap returns null....,it working before updated database reference...,

 intent = getintent();             final string key = i.getextras().getstring("firekey");             log.d("inter", key);              // initialize database             query queryref = firebasedatabase.getinstance().getreference()                     .child("reports").orderbykey()                     .equalto(key);              string dd=queryref.tostring();             log.d("query", dd);      queryref.addchildeventlistener(new childeventlistener() {                  @override                  public void onchildadded(datasnapshot datasnapshot, string s) {                     log.d(tag, "onchildadded:" + datasnapshot.getref());                      map<string, object> newpost = (map<string, object>) datasnapshot.getvalue();                     if (newpost != null) {                         reportsingle = new fooditem(newpost.get("meal_title").tostring().trim(),                                 newpost.get("description").tostring().trim(),                                 newpost.get("meal_ingredients").tostring().trim(),                                  newpost.get("meal_price").tostring().trim(),                                 newpost.get("meal_category").tostring().trim(),                                 newpost.get("meal_quantity").tostring().trim(),                                 newpost.get("meal_nutritional_value").tostring().trim(),                                 newpost.get("meal_type").tostring().trim(),                                 newpost.get("location").tostring().trim(),                                 newpost.get("picture").tostring().trim(),                                 datasnapshot.getref(),                                 newpost.get("votes").tostring().trim());                           string s1 = reportsingle.getingredients().trim();                         log.d("single", s1);                         singleingredients.settext(reportsingle.getingredients());                         singlequantity.settext(reportsingle.getquantity());                         singlenutritionalvalue.settext(reportsingle.getquantity());                         singlemealtype.settext(reportsingle.getmeal_type());                          singlelocation.settext(reportsingle.getlocation());                         //singleinstitution.settext(reportsingle.getinstitution());                          singletitle.settext(reportsingle.gettitle());                         singledescription.settext(reportsingle.getdescription());                           string photobrew = reportsingle.getpicture();                       }else{                         log.d("none", "none");                     }                  }                  @override                 public void onchildchanged(datasnapshot datasnapshot, string s) {                  }                  @override                 public void onchildremoved(datasnapshot datasnapshot) {                  }                  @override                 public void onchildmoved(datasnapshot datasnapshot, string s) {                  }                  @override                 public void oncancelled(databaseerror databaseerror) {                      // getting post failed, log message##                     string s=databaseerror.toexception().tostring();                     log.d( "post:cancelled", s);                      toast.maketext(mealdetailsactivity.this, "failed load data.",                             toast.length_short).show();                  }             });            } 


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -