0

Why do I get an error with this code?

public Cursor getAllTitlesFromInnerListGroup(String tablename, String grp) {
    String[] columns = new String[]{KEY_ROWID_T, KEY_NAME_T, KEY_PRIORITY_T, KEY_FINISHED_T, KEY_NOTES_T, KEY_HIDDEN_T, KEY_QUANTITY_T, KEY_GROUP_T};
    //return ourDatabase.query("GL_" + tablename, columns, KEY_GROUP_T + "='Volvo'", null, null, null, null); //this works
    return ourDatabase.query("GL_" + tablename, columns, KEY_GROUP_T + "=" + grp, null, null, null, null);
}

04-18 21:10:53.118: E/AndroidRuntime(30721): Caused by: android.database.sqlite.SQLiteException: no such column: Volvo: , while compiling: SELECT _id, grlist_name, grlist_priority, grlist_finished, grlist_notes, grlist_hidden, grlist_quantity, grlist_group FROM GL_table WHERE grlist_group=Volvo

1 Answer 1

2

Change this:

return ourDatabase.query("GL_" + tablename, columns, KEY_GROUP_T + "=" + grp,
null, null, null, null);

To this:

return ourDatabase.query("GL_" + tablename, columns, KEY_GROUP_T + "= ?" ,
new String[]{grp}, null, null, null);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.