我有一个带有以下创建语句的简单地址表:
"CREATE TABLE " + ADDRESSES_TABLE + " (" +
KEY_ADDRESS_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
KEY_ADDRESS_COUNTRY + " TEXT, " +
KEY_ADDRESS_CITY + " TEXT, " +
KEY_ADDRESS_STREET + " TEXT, " +
KEY_ADDRESS_HOUSE + " TEXT, " +
KEY_ADDRESS_POSTAL_CODE + " TEXT," +
"UNIQUE("+KEY_ADDRESS_COUNTRY+","+KEY_ADDRESS_CITY+","+KEY_ADDRESS_STREET+","+KEY_ADDRESS_HOUSE+","+KEY_ADDRESS_POSTAL_CODE +") ON CONFLICT IGNORE)"
当我添加重复记录时, insert() 方法返回 -1 而不是现有行的 id。
这个问题只能在 4.0+ 上重现。该方法在 2.2 和 2.3.3 上按预期工作。
有没有人遇到过同样的问题?