rawQuery: bind or column index out of range

android, database, sqlite

Solution

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 = ?"`.

Problem

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?

Original source