title: Android: inserting sqlite record with AUTOINCREMENT column
body: <p>I have an sqlite database on android created like this:</p>
  
  <pre><code>sqlite&gt; .schema
  CREATE TABLE criterion ('_id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, active text, important text, sort int, summary text, user text, category_id int, entrytype int);
  </code></pre>
  
  <p>The only way I can insert a record into this table is by specifying a value for <strong>_id</strong> which I want to auto-increment. This is the only way I can get the insert working:</p>
  
  <pre><code>recid = totalrecs + 1;
  String q = "insert into criterion (_id, active, important, sort, summary, user, category_id, entrytype) values (" + recid + ", \"1\", \"0\", 99, \"foobar\", \"1\", 99, 0)";
  Log.d (TAG, "query:" + q);
  mDb.execSQL (q);
  </code></pre>
  
  <p>If I leave the _id column out and don't specify a value for _id, I get an error:</p>
  
  <pre><code>android.database.sqlite.SQLiteConstraintException: criterion._id may not be NULL: insert into criterion(active, important, sort, summary, user, category_id, entrytype) values ("1", "0", 99, "foobar", "1", 99, 0)
  </code></pre>
  
  <p>How do I arrange the query (or schema) so Android will take care of incrementing the <strong>_id</strong> column? </p>
  
  <p><strong>Update/fixed 2 lines above (removed NOT NULL, removed _id from query):</strong></p>
  
  <pre><code>CREATE TABLE criterion ('_id' INTEGER PRIMARY KEY AUTOINCREMENT, active text, important text, sort int, summary text, user text, category_id int, entrytype int);
  
  String q = "insert into criterion (active, important, sort, summary, user, category_id, entrytype) values (\"1\", \"0\", 99, \"foobar\", \"1\", 99, 0)";
  </code></pre>