4
我可以使用手動ID [PRIMARY KEY AUTO INCREMENT]值使用db.insert方法插入到SQLITE數據庫嗎?或者我必須用SQL命令使用rawQuery方法來完成它?帶手動ID(主鍵)的SQLITE INSERT
mylibman ... // Is a custom class containing all values
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
//values.put(KEY_ID, mylibman.getBookid()); //If I put this line, ID always becomes zero
values.put(KEY_NAME, mylibman.getBookname());
values.put(KEY_PRINT_NAME, mylibman.getPrintname());
long numrow = db.insert(TABLE_NAME, null, values);
db.close();
感謝,