cursor - i want number of rows in android -
i using cursor.getcount not working confused. trying data labels against given date not working.
@override public void onclick(view v) { // todo auto-generated method stub date=et.gettext().tostring(); cursor= db.rawquery("select count(*) labels date='" + date + "'", null); // db.opendatabase(path, factory, flags) // log.d("query", "select count(*) labels date='" + date + "'"); //log.d("cursor length", ) if(cursor!=null && cursor.getcount()>0) { cursor.movetofirst(); toast.maketext(getapplicationcontext(), "already exist", toast.length_short).show(); } else{ toast.maketext(getapplicationcontext(), "please download latest data", toast.length_short).show(); return; } }
change query as
"select count(*)as count labels date='" + date + "'"
replace if(cursor!=null && cursor.getcount()>0)
if(cursor!=null && cursor.getint(cursor.getcolumnindex("count"))>0)
or in other way can change query as
"select * labels date='" + date + "'"
and other code work same have done.
Comments
Post a Comment