0
我嘗試只在電話號碼(號碼)不存在的情況下將一些值(消息正文和日期)插入數據庫,但我的代碼無法正常工作。你能提出一些建議嗎?Android/SQLite。通過過濾在數據庫中插入多個值?
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery("INSERT INTO version2 (number, body, date) values ("+number+","+body+","+ date+") SELECT "+number+" WHERE NOT EXISTS "
+ "(SELECT 1 FROM version2 WHERE number = "+number+")", null);
if (cursor.moveToFirst()) {
do {
} while (cursor.moveToNext());
}
}