I am developing a restaurant menu application. My application has a sqlite table that has the following columns:
"id", "category", "item_name"
The content of a category column has a type string. The primary key of the table id.
I want to receive data of a certain category.
For example, I want to get the element names of all the elements that belong to a category Veg, and then display this result in a list.
I tried different requests, but both of them do not work. Please help me.
String vg ="Veg";
Cursor mCursor = database.query(true, DATABASE_TABLE, new String[] {
KEY_ROWID, KEY_CATEGORY, KEY_NAME,KEY_PRIZE,KEY_DESCRIPTION },
KEY_CATEGORY + "=" + vg , null, null, null,null, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
Raw request
String query = "SELECT * FROM todo WHERE category =" + vg ;
Cursor cursor = database.rawQuery(query,null);
if (cursor != null) {
cursor.moveToFirst();
}
return cursor;
sagar source
share