java - Android SQL update query returns 1 but not updating -
i'm trying update simple boolean value in sql table per docs here: updating db row, developer.android.com
when attempt update table, update statement returns 1 after closing , re-opening app database remains unchanged. here code:
in mainactivity.java:
void checkunchecktodaytask (string taskid, boolean newstate) { new checkunchecktodaytask().execute(taskid, string.valueof(newstate)); } class checkunchecktodaytask extends asynctask<string, void, void> { @override protected void doinbackground(string... strings) { sqlitedatabase db = mdbhelper.getreadabledatabase(); // new value 1 column contentvalues values = new contentvalues(); values.put(taskcontract.todaytask.column_name_completed, boolean.valueof(strings[1])); // row update, based on title string selection = taskcontract.todaytask._id+ " = ?"; string[] selectionargs = { strings[0] }; db.update( taskcontract.todaytask.table_name, values, selection, selectionargs); return null; } }
in todaytaskadapter.java:
mcompletedcheckbox = (checkbox) view.findviewbyid(r.id.cb_today_completed); mcompletedcheckbox.setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() { @override public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { if (ischecked) { mcompletedcheckbox.setpaintflags(mcompletedcheckbox.getpaintflags() | paint.strike_thru_text_flag); mcompletedcheckbox.settextcolor(color.gray); ((mainactivity)activitycontext).checkunchecktodaytask(string.valueof((long)mcompletedcheckbox.gettag(r.id.tag_check_box)), true); } else { mcompletedcheckbox.setpaintflags(mcompletedcheckbox.getpaintflags() & (~ paint.strike_thru_text_flag)); mcompletedcheckbox.settextcolor(color.black); ((mainactivity)activitycontext).checkunchecktodaytask(string.valueof((long)mcompletedcheckbox.gettag(r.id.tag_check_box)), false); } } });
the click handler indeed being called , passing taskid value of 1 , newstate value of true when checked.
i have tried changing using getwriteabledatabase, using instead of = in clause, , stepping through code line-by-line, no errors thrown.
thanks!
Comments
Post a Comment