need help with androids sql query
I have an error in that m
String currentDateTimeString = DateFormat.getDateInstance().format(new Date());
Cursor myCursor=db.query(true, DATABASE_TABLE, new String[]{KEY_ROWID,MONEY_FIGURE,SPENDING_DETAILS,DATE}
, KEY_ROWID , null, null, DATE+"="+currentDateTimeString, KEY_ROWID, null);
The query function by the androids api:
query(boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit)
What I am trying to do here is to say. give me all the data based on where the date equals currentDateTimeString .
But I get an error on that statement.. dont ask me what the error is..when i remove the call to the method holding that query statement the error doesnt appear..so i guess it is an sqlexception
SOLVED MY ME:
Cursor myCursor=db.query(true, DATABASE_TABLE, new String[]{KEY_ROWID,MONEY_FIGURE,SPENDING_DETAILS,DATE}
,DATE+"='"+currentDateTimeString+"'" , null, null, null , KEY_ROWID, null);
I am trying to do this
SELECT MONEY_FIG开发者_C百科URE,SPENDING_DETAILS,DATE
FROM SpendingManagmentTable
WHERE Date=@ currentDateTimeString
If the column type is not number then have to use with ''
date='1/1/2011' not date=1/1/2011
Cursor c = db.query(DATABASE_TABLE, new String[] {{KEY_ROWID,MONEY_FIGURE,SPENDING_DETAILS,DATE},DATE+"='"+currentDateTimeString+"'", null, null, null, null);
精彩评论