Use an example to explain the recent encounter with a problem.
In the android sqlite3 command line, execute CREATE TABLE T (a). The specific type of a is not specified here.
Then execute INSERT into T values (0).
If I use "select * from t where a = 0" in the sqlite3 command line, the query succeeds and fails if "select * from T where a= ' 0 '".
The reason is I'm calling Values.put ("a", 0), and 0 is an integer, so the database is considered a number. So the where uses ' 0 ', the database does not know what type the column should use, so it will not be converted into a number, so the query is not the thing.
If you create table T (a integer), specifying that the type of a is integer, the two statements will be successful.
Because the SQL parser knows the specific type of the column, even if you specify string ' 0 ' to come in, you can still automatically convert to the number 0 and then query.
When writing a program in Java, because sqlitedatabase.rawquery specifies that the SQL parameter must be of type string, if you do not specify a specific type when you create the table, the string does not automatically convert to a number, then the query fails.
One benefit of specifying types when Android sqlite CREATE table