我有一个带有这些参数的SQLite数据库
private static final String TABLE_NAME = "people_table";
private static final String COL1 = "ID";
private static final String COL2 = "name";
private static final String COL3 = "anything";
创建方式如下:
String createTable = "CREATE TABLE " + TABLE_NAME + " (ID INTEGER PRIMARY KEY AUTOINCREMENT, " +
COL2 +" TEXT, " + COL3 + "TEXT)" ;
我试图将数据添加到数据库中,对于这两列,我的代码都在这里:
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(COL2, "item");
contentValues.put(COL3, "item2");
long result = db.insert(TABLE_NAME,null,contentValues);
if (result > 0) {
return true;
} else {
return false;
}
但是它不起作用,我不知道为什么。
拜托,有什么建议吗?
答案 0 :(得分:0)
您的问题是您省略了空格,所以没有名为 anything 的列,而是名为 anythingTEXT
的列更改为使用:-
public function customer() {
return $this->hasOne('App\Models\Customer');
}
然后删除该应用程序的数据,或卸载该应用程序并重新运行。