android - How to save query result in string -


given below sqlite query. how save result in string? want save query result in string. below query give result in sqlite editor, want in code.

select count(*),sum(fare)  jobs timeweek  > '2014/03/24 20:20'  private static final string key_compid = "_compid"; private static final string key_timejob = "timejob"; private static final string key_timeweek = "timeweek";    private static final string key_pick = "pick"; private static final string key_dest = "dest"; private static final string key_fare = "fare";                         + key_time + " text" + ")";     string create_completed_table = "create table " + table_completed_jobs             + "(" + key_compid + " integer primary key," + key_timejob             + " text,"   + key_pick + " text," + key_dest + " text,"             + key_fare + " text,"             + key_timeweek + " datetime" + ")";  public string  totaljobsaearnafterlogin() { int cnt;  string selectquery = "select count(*),sum(fare)  from" +      table_completed_jobs + " " +key_timeweek+"  > '2014/03/24 20:10'";      sqlitedatabase db = this.getwritabledatabase(); cursor cursor = db.rawquery(selectquery, null); // looping through rows , adding list   //cursor.movetofirst(); cnt= cursor.getcount();  cursor.close();  db.close(); 

string selectquery = "select count(*) count ,sum(fare) fare  from" +      table_completed_jobs + " " +key_timeweek+"  > '2014/03/24 20:10'";      cursor cursor = db.rawquery(selectquery, null); cursor.movetofirst(); cnt= cursor.getcount(); if(cnt > 0) {    int count = cursor.getint(cursor.getcolumnindex("count"));     int faresum = cursor.getint(cursor.getcolumnindex("fare"));     string result = count + " " + faresum; } cursor.close(); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -