I have a table in my db like this :
. . .
String contactsTableName = TABLE_CONTACTS;
// creating the "contacts" table
buf.append("CREATE TABLE IF NOT EXISTS ");
buf.append(contactsTableName);
buf.append(" (");
buf.append("_id INTEGER PRIMARY KEY,");
buf.append("username TEXT,");
buf.append("nickname TEXT,");
buf.append("provider INTEGER,");
buf.append("account INTEGER,");
buf.append("contactList INTEGER,");
buf.append("type INTEGER,");
buf.append("subscriptionStatus INTEGER,");
buf.append("subscriptionType INTEGER,");
. . .
And now i want to change this table and make username
column UNIQUE
, I wrote the onUpgrade()
method i don’t know how is sql syntax for this purpose.
I change this code like this in my onCreate()
:
buf.append("username TEXT UNIQUE");
I hope i explain my problem clear and apologise for my poor English. :)