Q:

Set Auto increment to a column in Sqlite database in android

I have used the following code to create a database using Sqlite. I have set auto increment to a column. When I try to insert values to the table it gives error.
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" + "\");");

Error:
 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");

A:

When you try to insert you should insert it this way. The SQlite framework will insert the auto-incremented values to the user_id column by itself.
INSERT INTO test.authors (username,age, zipcode,gender,isstored) VALUES ("kumar","23","1234","M", "ok");

