coderslay
coderslay

Reputation: 14370

Not able to add unique rows using sqlite in android

I am working on Android 2.3 Simulator.

I have some 5 unique categories...

I need to add these categories in my table....

I added it using primary key like this

Create table if not exists test (category integer primary key, value text) ;

But if i execute this query twice

insert into test(category, value) values(1,"0");

Then it is adding this twice

Even if i use unique like this

Create table if not exists test (category integer unique, value text) ;

Then also it is adding the row twice...

How to make a row unique?

Upvotes: 0

Views: 127

Answers (1)

dont add record manually ie for primary key, you can assign primary key as auto increment, let system will add record.

Upvotes: 1

Related Questions