I am trying to select some data from a database, and I have two pieces of code:
cursor = builder.query(db, new String[]{"col1", "col2", "col3"}, "id = ?", new String[]{getSID(db)}, null, null, null);
and
cursor = builder.query(db, new String[]{"col1", "col2", "col3"}, "id = " + getSID(db), null, null, null, null);
The difference between the two is that the first seems more correct according to the documentation, but it also does not work - the cursor is empty. Instead of the second, I get all the necessary data.
So, I tried to execute different SQL queries on my computer with a copy of the database and what I have:
SELECT col1, col2, col3 FROM SomeTables WHERE (id = '42')
This does not work (and this query is obviously equal to the query generated by the first code sample)
SELECT col1, col2, col3 FROM SomeTables WHERE (id = 42)
And this one works fine (equal to the request from the second code sample).
As I know, SQLite should do the type auto run, but something went wrong and I donβt know why. Do you have any ideas on how to fix the first code sample? (Or maybe a database?)
If that matters, the CREATE script of the table with the id field is simplified here:
CREATE TABLE SomeTable ( ID PRIMARY KEY, col1, col2, [...] )
UPD: And by the way, getSID (db) returns a String Object.