Reputation: 6718
I'm trying to execute the following sqlite statement inside my android app:
String sql = "SELECT ID, lt, lg FROM Location WHERE ABS(lt-?) <= ? AND ABS(lg-?) <= ?";
I have tried using 'rawQuery' in the following sql statement:
String sql = "SELECT ID, lt, lg FROM Location WHERE ABS(lt-" + lt + ") <= " + ltGridLen + " AND ABS(lg-" + lg + ") <= " + lgGridLen + " LIMIT 1";
which worked. However, I want to know whether there is any other more efficient way to do this.
Upvotes: 0
Views: 1038
Reputation: 180010
rawQuery
accepts parameters to bind, but only as an array of String
s.
Comparing an integer against a string will not work correctly.
With integers, there are no problems with formatting or SQL injection, so you do not need to use parameters for them.
Upvotes: 2