【发布时间】:2016-10-05 09:37:25
【问题描述】:
我有以下 SQLite 查询:
ArrayList<Long> idList = new ArrayList<>();
// adding Long values to idList
SQLiteDatabase db = getReadableDatabase();
final String whereClause = COLUMN_DEVICE_ID + " IN (?)";
final String[] whereArgs = new String[]{TextUtils.join(", ", idList)};
Cursor cursor = db.query(TABLE_DEVICES, null, whereClause, whereArgs,
null, null, null);
执行此查询会产生一个空的Cursor。
问题的原因似乎是whereArgs String 没有插入whereClause。
我调试了代码,发现Cursor的mQuery字段被初始化为如下:
SELECT * FROM table_devices WHERE device_id IN (?)
为什么? 没有被whereArgs 取代?
提前致谢。
【问题讨论】:
-
执行TextUtils.join(", ", idList)会得到什么?
标签: android sqlite android-sqlite