如何在android sqlite中将主键添加到text数据类型?

sai*_*sai 6 sqlite android

可能重复:
是否可以在android数据库的文本字段中应用主键

我已经做了这样的力量关闭.

private static final String CREATE_NEWCUSTOMER = "create table newcustomer (_id integer primary key autoincrement, "
            + "cname text primary key, date text , " + "caddress text);";
Run Code Online (Sandbox Code Playgroud)

它适用于整数,如果有任何想法请帮助我.

Tho*_*mar 7

您不会在SQLite中创建类似主键.我没有测试过以下内容,但根据文档它应该可以工作:

private static final String CREATE_NEWCUSTOMER = "create table newcustomer (_id integer autoincrement, cname text, date text, caddress text, PRIMARY KEY(_id, cname));";
Run Code Online (Sandbox Code Playgroud)