I'm currently trying to query my SQLite database using the following line of code:
public Cursor getExpenses(String username)
{
SQLiteDatabase db = this.getWritableDatabase();
Cursor results = db.rawQuery("SELECT * FROM " + TABLE_EXPENSES + " WHERE username = " + username , null);
DatabaseUtils.dumpCursorToString(results);
return results;
}
The problem is the parameter username
does not get passed into the query and instead I get returned all the data in TABLE_EXPENSES
. If I leave out the quotes, I get no such column
error. I was thinking of escaping the double quotes on username
but apparently after some searching it seems like you can't escape the characters on SQLite? Hence, my question: How do I pass the parameter into the query.