Created a table

"CREATE TABLE student ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, course TEXT)"

Now when trying to insert a row like

String sql = "INSERT INTO student" +" VALUES (?,?)";
SQLiteStatement statement = myWriteableDatabase.compileStatement(sql);
statement.clearBindings();
statement.bindString(2, "Some Name");
statement.bindString(3, "Some Course");
statement.execute();

this throws an exception saying

table student has 3 columns but 2 values were supplied: , while compiling: INSERT INTO student VALUES (?,?);

Why is this exception even though I have made id column as AUTOINCREMENT.

Related posts

Recent Viewed