Q:

WHERE clause in Android SQLite

String[] columns = new String[]{ KEY_NAME, KEY_NUM };
Cursor c = ourDatabase.query(DATABASE_TABLE, columns, KEY_NAME + "=" + name, null, null, null, null); 

This is the code I am using for returning those columns which match a particular string I have passed in i.e. name. However, this does not work. Also, If I replace the 'where' clause by null, all the rows are returned correctly. Please Help. Thanks!
The source table rows are thus
public static final String KEY_ROWID = "_id";
public static final String KEY_NAME = "surveyString";
public static final String KEY_NUM = "numOfQuestions";

A:

Have you tried put ' between the variable?
Cursor c = ourDatabase.query(DATABASE_TABLE, columns, KEY_NAME + "='" + name + "'", null, null, null, null); 

