Given the following code:
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);"); A table is created in SQLite.
How can I get a lastID after adding a record?
With the following code:
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); I get -1.
DATEincreate table,DATAincontentValues. Fix that first.