给定以下代码:
sqLiteDatabase.execSQL("create table if not exists ACCOUNT (ID integer primary key autoincrement," +
"CASH LONG NOT NULL," +
"BANKID INTEGER NOT NULL," +
"ACCOUNTNO TEXT ," +
"DATE TEXT NOT NULL," +
"COMMENT TEXT);");
在 SQLite 中创建一个表。
添加记录后如何获取lastID?
使用以下代码:
contentValues.put("CASH", accountTO.getCash());
contentValues.put("DATA", DatePro.currentDate());
contentValues.put("BANKID", accountTO.getBankID());
contentValues.put("ACCOUNTNO", accountTO.getAccountNo());
contentValues.put("COMMENT", accountTO.getComment());
Long i = sqLiteDatabase.insert("ACCOUNT", null, contentValues);
我明白了-1
。