java - cursor wont return a row no matter what -
i'm trying latest row have inserted db, cursor. have tried many types of query, , nothing seem work.
, here code:
public expense createexpense(expense expense) { contentvalues values = new contentvalues(); values.put(expdatabase.column_description, expense.getdesc()); values.put(expdatabase.column_amount, expense.getamount()); values.put(expdatabase.column_date, expense.getdate().tostring()); values.put(expdatabase.column_category, expense.getcategory()); integer insertid =(int) database.insert(expdatabase.table_name, null, values); string id="'"+insertid.tostring()+"'"; cursor c = database.query(expdatabase.table_name, null, null, null, null, null, null); int i= c.getcount(); cursor cursor= database.query(expdatabase.table_name, null,expdatabase.column_id+"="+id, null, null, null, null); *the insert method works, have seen row in db table. *the getcount returns same number insertid
but when try last row cursor, nothing, see in cursor returned -1 in number of rows.
im lost. please me :(
if i'm not mistaken have problem on query
string[] fields = new string[]{expdatabase.column_id}; cursor cursor= database.query(expdatabase.table_name, fields,expdatabase.column_id+"="+id, null, null, null, null);
Comments
Post a Comment