android - SQLite database Text column parser to double -
i wanted query sqlite db , query cost, text in sqlite.
want sum of column value.
how do it?
here's code
public class estimate extends appcompatactivity { databasehandler db; textview tv; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_estimate); db=new databasehandler(this); tv=(textview)findviewbyid(r.id.textview2); tv.settext("joma="+getjoma()+""); } public double getjoma(){ double sum=0.0; sqlitedatabase dt = db.getreadabledatabase(); cursor res = dt.rawquery("select cost tb type=জমা",null); do{ sum =sum+ double.parsedouble(res.getstring(res.getcolumnindex("cost"))); } while(res.movetonext()); return sum; } }
Comments
Post a Comment