Sqlite Error 'column _id Is Not Unique' On When Inserting Into An Empty Table
Solution 1:
'column _id is not unique (code 19)'
So you are violating UNIQUE
Constraint. This is reason of SQLiteConstraintException. Your _id
column is most likely primary key and primary keys have implicitly assigned UNIQUE
constraint that say no two rows can have same primary key.
You are trying to insert duplicit _id
that already is in db or PK
is assigned to NULL
.
I tried querying the size of the table and found it is 0, so I have no idea where this is coming from.
I think your query was broken because your Exception
says everything and it cannot be thrown if somewhere is not a problem.
Update:
If you are not assigned NULL
to PK
and also your table has 0 records probably problem is here:
mDatabase.insertOrThrow("groups", null, mContentValues);
You are assigned NULL
to ColumnHack as second param of insert()
method that you shouldn't. In SQLite, each row must have at least one column specified. It needs one column that can be safe assigned to NULL
.
Post a Comment for "Sqlite Error 'column _id Is Not Unique' On When Inserting Into An Empty Table"