我使用以下代码使用 Sqlite 创建了一个数据库。我已将自动增量设置为一列。当我尝试向表中插入值时,它会出错。
db.execSQL("CREATE TABLE IF NOT EXISTS "
+ SAMPLE_TABLE_NAME
+ " (user_id INTEGER PRIMARY KEY AUTOINCREMENT, username VARCHAR,age VARCHAR, zipcode VARCHAR,gender VARCHAR,isstored VARCHAR);");
db.execSQL("INSERT INTO " + SAMPLE_TABLE_NAME + " Values ("
+ "\"" + name + "\"," + "\"" + age
+ "\",\"" + zip + "\",\"" + gender + "\", \""
+ "ok" + "\");");
错误:
09-28 09:44:54.545: E/AndroidRuntime(3825): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.readometer/com.readometer.ReadometerSplash}:
android.database.sqlite.SQLiteException: table USERDETAILS has 6 columns but 5 values were supplied (code 1): , while compiling: INSERT INTO USERDETAILS Values ("kumar","23","1234","M", "ok");