我正在尝试使用 BETWEEN 运算符通过 Android 比较 sqlite 中的纬度和经度值。问题是该值总是被比较,就好像它是一个字符串,我不知道如何将它作为一个数字进行比较。我发现这一点是因为使用查询“select * from database orderby latitude”会返回一个未按数字排序的列表。KEY_LAT 和 KEY_LONG 我存储为 TEXT 和 REAL,并且得到相同的输出。请告诉我您需要什么信息。
这是查询:
double high_lat = curr_lat + 100.0;
double high_long = curr_longitude + 100.0;
double low_lat = curr_lat - 100.0;
double low_long = curr_longitude - 100.0;
Cursor cursor = db.query(TABLE_NAME, new String[] {KEY_ID, KEY_NAME, KEY_ADDR, KEY_LAT, KEY_LONG}, select,
new String[]
{KEY_LAT + " BETWEEN " + low_lat + " AND "
+ high_lat + " AND " + KEY_LONG + " BETWEEN " + low_long + " AND "
+ high_long},
null, null, null);