android - Retrieve already saved data from firebase database and displaying it on several textviews in a new activity -


package com.example.ogho.thesistorone;  import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.widget.button; import android.widget.textview;  import com.google.firebase.auth.firebaseauth; import com.google.firebase.auth.firebaseuser; import com.google.firebase.database.datasnapshot; import com.google.firebase.database.databaseerror; import com.google.firebase.database.databasereference; import com.google.firebase.database.firebasedatabase; import com.google.firebase.database.valueeventlistener;  import org.w3c.dom.text;  public class orderactivity extends appcompatactivity {      private firebaseauth mfirebaseauth;     private firebaseuser mfirebaseuser;      private string muserid;     databasereference db;     boolean saved = false;     button btnstatus;     textview txtcourse,txttypofjob,txtduration,txtprice,txttopic;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_profile);          txtcourse=(textview)findviewbyid(r.id.txtcourse);         txttypofjob=(textview)findviewbyid(r.id.txttypofjob);         txtduration=(textview)findviewbyid(r.id.txtduration);         txtprice=(textview)findviewbyid(r.id.txtprice);         txttopic=(textview)findviewbyid(r.id.txttopic);         btnstatus=(button)findviewbyid(r.id.btnred);            getsupportactionbar().setdisplayuselogoenabled(true);         getsupportactionbar().setdisplayshowhomeenabled(true);         getsupportactionbar().seticon(r.mipmap.thsstrn);          mfirebaseauth = firebaseauth.getinstance();         mfirebaseuser = mfirebaseauth.getcurrentuser();          if (mfirebaseuser == null) {             loadloginview();         } else {             muserid = mfirebaseuser.getuid();              db = firebasedatabase.getinstance().getreference().child("client").child(muserid).child("orders");           }         db.addvalueeventlistener(new valueeventlistener() {             @override             public void ondatachange(datasnapshot datasnapshot) {                  (datasnapshot postsnapshot : datasnapshot.getchildren()) {                      orders value = postsnapshot.getvalue(orders.class);                /* string type = null;                 if (value != null) {                     type = value.gettype();                 }                 string duration = null;                 if (value != null) {                     duration = value.getduration();                 }                 string topic = null;                 if (value != null) {                     topic = value.gettopic();                 }                 string price = null;                 if (value != null) {                     price = value.getprice();                 }                 string traffic = null;                 if (value != null) {                     traffic = value.getuid();                 }*/                      string type="type of order:  "+value.gettype();                     string duration="duration:  "+value.getduration();                     string topic="topic:  "+value.gettopic();                     string price="price:  "+value.getprice();                     string traffic="status:  "+value.getuid();                      client k = datasnapshot.getvalue(client.class);                     /*string name = null;                     if (k != null) {                         name = k.getname();                     }*/                     string name="name:  "+k.getname();                      txtcourse.settext(name);                     txttypofjob.settext(type);                     txtduration.settext(duration);                     txttopic.settext(topic);                     txtprice.settext(price);                     btnstatus.settext(traffic);                  }             }             @override             public void oncancelled(databaseerror databaseerror) {              }         });     }      private void loadloginview() {         intent intent = new intent(this, loginactivity.class);         intent.addflags(intent.flag_activity_new_task);         intent.addflags(intent.flag_activity_clear_task);         startactivity(intent);     }      @override     public boolean oncreateoptionsmenu(menu menu) {         getmenuinflater().inflate(r.menu.menu_main, menu);         return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {          int id = item.getitemid();          if (id == r.id.action_logout) {             mfirebaseauth.signout();             loadloginview();         }else if(id==r.id.edit_profile){             intent = new intent(this, mainactivity.class);             startactivity(i);             //startactivity(new intent(this,mainactivity.class));             return true;         }          return super.onoptionsitemselected(item);     } } 

i trying display saved data firebase , displaying on several textviews , doesn't so. here database class

package com.example.ogho.thesistorone;  /**  * created ogho on 25/07/2017.  */  public class orders {  public string course; public string level; public string type; public string topic; public string duration; public string otherinfo; public string price; public string uid;  public orders(){  }  public string getcourse() {     return course; } public string getlevel() {     return level; } public string gettype() {     return type; } public string gettopic() {     return topic; } public string getduration(){     return duration; } public string getotherinfo(){     return otherinfo; } public string getprice(){     return price; } public string getuid() {     return uid; }   public void setcourse(string course){     this.course = course; } public void setlevel(string level){     this.level = level; } public void settype(string type){     this.type = type; } public void settopic(string topic){     this.topic = topic; } public void setduration(string duration){     this.duration=duration; } public void setprice(string price){     this.price=price; } public void setotherinfo(string otherinfo){     this.otherinfo=otherinfo; } public void setuid(string uid){     this.uid = uid; }  public orders(string topic, string course, string duration, string level, string otherinfo, string price , string type, string uid) {     this.course = course;     this.level = level;     this.type = type;     this.topic = topic;     this.duration = duration;     this.otherinfo = otherinfo;     this.price = price;     this.uid = uid; } } 

what wrong code? need tying retrieve , displaying data database on user interface.

{  "client" : {               "course_of_study" : "computer engineering",                "institution" : "rhodes university",                "name" : "ogho enuku"   },   "orders" : {               "course" : "kfdfk",               "duration" : "7",               "level" : "bachelors",               "otherinfo" : "jddj",               "price" : "requested",               "topic" : "jddj",               "type" : "coursework/assignment",               "uid" : "requested quotation"   } 

here json file requested firebase realtime database @alexmamo


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -