I am querying my db. When I use an int for the selection part I get the info returned I want. When I use a string for selection I get nothing returned. Is there a different way to query when using a string or am I doing something wrong. This function worked when I passed in an int, but when I pass in a string it does not work. I used breakpoints and the parameters are correct going into the function, but it does not retrieve the data from the db.
Here is the code
public String childFound(String item_name)throws Exception
{
Cursor c = db.query(DB_TABLE, new String[] { KEY_INSPECTION_ID, KEY_ITEM_NAME},
"item_name="+ item_name, null, null, null, null);
int id=c.getColumnIndex(KEY_ITEM_NAME);
c.moveToFirst();
String result=c.getString(id);
c.close();
return result;
}
If I change the String item_name to int inspectionItem it works. I am also including where I declared my variable for the db.
public class InspectionRecordsTableDBAdapter {
private static final String KEY_ROWID = "_id";
private static final String KEY_INSPECTION_ID = "inspection_id";
private static final String KEY_PARENT_NAME = "parent_name";
private static final String KEY_ITEM_NAME = "item_name";
private static final String KEY_COMMENT = "comment";
private static final String KEY_STATUS = "status";
private static final String DB_TABLE = "inspection_records";
private Context context;
private SignalSetDBHelper dbHelper;
private SQLiteDatabase db;
private SQLiteOpenHelper openHelper;
If you need more code let me know.
should be
Think you are missing the quotes