Hashey100 Hashey100 - 8 days ago 5
Android Question

Error when trying to insert a new variable into a database

I'm trying to insert a new varibale called

KEY_DAY
but whenever I try to insert it into the database, I get an error. Any suggestions on how to solve this problem?

Answer
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);

}
Comments