Reputation: 2221
Cursor cursor = db.rawQuery("SELECT id,lastname FROM people WHERE lastname='John Kenedy'; ",null);
Is that correct usage of comparing String
? if no, How can I compare String
values in the database?
Upvotes: 1
Views: 9069
Reputation: 33495
For better performance, you should use rawQuery
method with selectionArgs
which is faster and more secure against adding directly data to statement. So try it like this
Cursor cursor = db.rawQuery("SELECT id,lastname FROM people WHERE lastname = ?; ", new String[] {"John Kenedy"});
Upvotes: 7