0

我试图在我的数据库中插入一些值,如下所示:

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 表是空的,有什么建议吗?

4

1 回答 1

0

在您的代码中的某个时间点COUNTRY具有该值Countrytext,并且已使用该列创建了表。使用sqlite3.

$ adb shell sqlite3 /data/data/your.package.name/databases/your.db .schema
于 2013-07-11T04:02:27.987 回答