Return The Searched Data From Sqlite
I am trying to search an item in sqlite by using String, & trying to return description contained in that row. items are stored in the table named Articles with column name AS_
Solution 1:
In your query item
is string,So change
String strquery="select * from Articles where AS_name= "+item;
to
String strquery="select * from Articles where AS_name='" + item + "'";
Or this
Cursor cur=null;
cur = db.query("Articles", null, "AS_name" + "=?",
newString[] { item }, null, null, null, null);
instead of
Cursor cur=null;
String strquery="select * from Articles where AS_name= "+item;
cur=db.rawQuery(strquery,null);
And change
strvalue=cur.getString(0);
to
strvalue=cur.getString(cur.getColumnIndex("Desc_art"));
Solution 2:
add quotes to item:
"select * from Articles where AS_name= '" + item + "'";
And try to uninstall and reinstall app. If you made changes to the tables you need to uninstall and do a clean install.
Thank you, the app is not crashing , but it is returning the indexing based on 1 , not the description contained in column named Desc_art, can you help me further
What column are you trying to return here in position 0 from the table?
strvalue=cur.getString(0);
Post a Comment for "Return The Searched Data From Sqlite"