【发布时间】:2018-11-15 07:58:48
【问题描述】:
我希望在 Kotlin 中使用 Anko 时为 SQLite 的表定义一个非空字段。
但是DBRecordTable.Category to TEXT NOT NULL 出错了,我该如何解决?
代码
implementation "org.jetbrains.anko:anko-sqlite:$anko_version"
override fun onCreate(db: SQLiteDatabase) {
db.createTable( DBRecordTable.TableNAME , true,
DBRecordTable._ID to INTEGER + PRIMARY_KEY+ AUTOINCREMENT,
DBRecordTable.Category to TEXT NOT NULL, //It's wrong
DBRecordTable.Content to TEXT,
DBRecordTable.IsFavorite to INTEGER +DEFAULT("0"),
DBRecordTable.IsProtected to INTEGER +DEFAULT("0"),
DBRecordTable.CreatedDate to INTEGER
)
}
【问题讨论】:
-
“错误”是什么意思?它有语法错误?还是运行时?
-
谢谢!它显示
Unresolved reference: NULL,无法编译。
标签: android kotlin android-sqlite anko