I seem to have run into difficulties with a simple database insert statement.
I’m inserting something into the database then (for debugging reasons) checking the number of rows. For the first example this doesn’t work. For the second “rawQuery” it does. Am I overlooking something simple? I’ve used this method loads of times before with no problems!
This doesn’t work:
contentValues = new ContentValues();
contentValues.put("classId", cursor.getString(0));
contentValues.put("to_do", toDo);
contentValues.put("date", date);
out("SIZE OF TODO+"+fetchCount());//returns 105
db.insert("toDo", null, contentValues);
out("NEW SIZE OF TODO+"+fetchCount());//still returns 105!
this does:
out("SIZE OF TODO+"+fetchCount()); //returns 105
db.execSQL("insert into toDo values(null, "+cursor.getString(0)+", '"+toDo+"', '"+date+"')");
out("NEW SIZE OF TODO+"+fetchCount());//returns 106
What’s going wrong?
I’m such an idiot, @Rob’s suggestion of looking at my create tables made me realise, I was referring to the wrong column name. It never occurred to me that an update statement like this could fail silently! Thanks @Rob