I am trying to get user by his name like that:
public Cursor GetUser(String username)
{
return m_dataBase.rawQuery("SELECT * FROM users WHERE name = \' ? \'", new String[] { username });
}
But then I got an exception "bind or column index out of range". What is wrong in my code?
You are trying to use a parameter, but such parameters never need to be quoted.
Your query actually searches for a user named "?
" (with spaces).
Just use "SELECT * FROM users WHERE name = ?"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With