我试图在我的数据库中插入一些值,如下所示:
ContentValues cv = new ContentValues();
cv.put(ID, adv.getId());
cv.put(NAME, adv.getName());
cv.put(COUNTRY, country);
db.insert(TABLE_NAME, null, cv);
但我收到以下错误:
E/SQLiteDatabase(19920): 插入错误 id=14024 name=Banorte Generali Country=Mexico E/SQLiteDatabase(19920): android.database.sqlite.SQLiteConstraintException: TableName.Countrytext 可能不是 NULL(代码 19)
下面是创建数据库的代码:
db.execSQL("create table " + TABLE_NAME + " (" + ID
+ " integer primary key not null,"
+ NAME + " text, " + COUNTRY +
" text not null"
+ ");");
我可能做错了什么?我检查了插入值是否为空但它们不是,我检查了重复项,bur 表是空的,有什么建议吗?