尝试将新变量插入数据库时​​出错

时间:2012-03-23 19:13:15

标签: android sqlite android-sqlite

我正在尝试插入一个名为KEY_DAY的新变量,但每当我尝试将其插入数据库时​​,都会出错。关于如何解决这个问题的任何建议?

1 个答案:

答案 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);

}