android - select query which return number of jobs after specific time -
how make query return total number of jobs after specific time below sqllite table getting current time using java how make query return me total number of jobs after specific time???
private static final string table_completed_jobs = "jobs"; 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" + ")"; string selectquery = "select * " + table_completed_jobs + " order "+key_timeweek+" ; string mydate = java.text.dateformat.getdatetimeinstance().format(calendar.getinstance().gettime());
assuming query have written works:
string selectquery = "select * " + table_completed_jobs + " order "+key_timeweek+" ;
in databasehandler class perform database operations use cursor count like:
db = this.getreadabledatabase(); cursor c = db.rawquery(selectquery); int counter; if(c != null) { counter = c.getcount(); } c.close(); return counter;
therefore: if counter=0
means there no records fetched, , if counter>0
means there records.
hope helps!
Comments
Post a Comment