我正在尝试插入一个名为KEY_DAY
的新变量,但每当我尝试将其插入数据库时,都会出错。关于如何解决这个问题的任何建议?
答案 0 :(得分:3)
public long createEntry(String name, String hotness) {
// TODO Auto-generated method stub
ContentValues cv = new ContentValues();
cv.put(KEY_NAME, name);
cv.put(KEY_HOTNESS, hotness);
//here the value of person day is null coz ur not inserting anything use may be
cv.put(KEY_DAY,""); or combine two functions to insert value together
return ourDatabase.insert(DATABASE_TABLE, null, cv);
}
public long createEntry1(String day) {
// TODO Auto-generated method stub
ContentValues cv = new ContentValues();//here the value is rest two fields is null
cv.put(KEY_DAY, day);
return ourDatabase.insert(DATABASE_TABLE, null, cv);
}