android - FirebaseDatabaseException: Cant convert object of type java lang long to type -
found in stack trace, problem? can this. trying retrieve object firebase using recyclerview.
my logcat
com.google.firebase.database.databaseexception: can't convert object of type java.lang.long type ysy.spreadsheet.databaseview @ com.google.android.gms.internal.zzbqi.zze(unknown source) @ com.google.android.gms.internal.zzbqi.zzb(unknown source) @ com.google.android.gms.internal.zzbqi.zza(unknown source) @ com.google.firebase.database.datasnapshot.getvalue(unknown source) @ com.firebase.ui.database.firebaserecycleradapter.parsesnapshot(firebaserecycleradapter.java:151)
my structure
public class databaseview { private integer bodytemp; private integer electrocardiogram; private integer perspirerate; public databaseview(){ } public databaseview(integer bodytemp, integer electrocardiogram,integer perspirerate){ this.bodytemp= bodytemp; this.electrocardiogram= electrocardiogram; this.perspirerate= perspirerate; } public integer getbodytemp() {return bodytemp;} public void setbodytemp(integer bodytemp) {this.bodytemp = bodytemp;} public integer getelectrocardiogram() {return electrocardiogram;} public void setelectrocardiogram(integer electrocardiogram) {this.electrocardiogram = electrocardiogram;} public integer getperspirerate() {return perspirerate;} public void setperspirerate(integer perspirerate) {this.perspirerate = perspirerate;} }
my view holder
public static class healthviewholder extends recyclerview.viewholder{ public textview healthbodytemp; public textview healthelectrocardiogram; public textview healthperspirerate; public healthviewholder(view v){ super(v); healthbodytemp =(textview)itemview.findviewbyid(r.id.bodytemp); healthelectrocardiogram= (textview)itemview.findviewbyid(r.id.electrocardiogram); healthperspirerate=(textview)itemview.findviewbyid(r.id.perspirerate);
read firebase
private databasereference mfirebasedatabasereference; private firebaserecycleradapter<databaseview, healthviewholder> mfirebaseadapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //intialize recyclerview mhealthrecyclerview = (recyclerview)findviewbyid(r.id.healthrecyclerview); mlinearlayoutmanager = new linearlayoutmanager(this); mlinearlayoutmanager.setstackfromend(true); mhealthrecyclerview.setlayoutmanager(mlinearlayoutmanager); //database initilization mfirebasedatabasereference = firebasedatabase.getinstance().getreference(); mfirebaseadapter = new firebaserecycleradapter<databaseview, healthviewholder>( databaseview.class, r.layout.database_view, healthviewholder.class, mfirebasedatabasereference.child(health))
Comments
Post a Comment