java - Table not updating on update though returning the opposite -
i have problem sqlite table "views" doesn't update upon update query.
the views table constructed follows, 2 foreign keys making identifying primary key:
create table views (description text, modulesid integer not null references modules(modulesid), eventid integer not null references events(eventid), primary key (modulesid, eventid));
using following code attempt, , appear, succeed in updating table, returned integer takes result of 1.
private sqlitedatabase database; public void updateviews(string description, int modulesid, int eventid) { contentvalues values = new contentvalues(); values.put(mydatabasemanager.views_description, description); string = "modulesid = " + modulesid + " , eventid = " + eventid; int = database.update(mydatabasemanager.table_views, values, where, null); }
so. int returned 1, indicating row indeed updated. attempt retrieve rows find description of supposedly updated row still null.
public list<views> getallviews() { list<views> views = new arraylist<views>(); cursor cursor = database.query(mydatabasemanager.table_views, allviewscolumns, null, null, null, null, null); cursor.movetofirst(); while (!cursor.isafterlast()) { views view = cursortoview(cursor); views.add(view); cursor.movetonext(); } cursor.close(); return views; }
this true without closing application.
i have no visible errors in code, , nor seem able make out of logcat. leads me believe have done fundamentally wrong somewhere in code. in code haven't posted, perhaps can make out might have gone wrong.
i not proficient @ programming best follow get. thanks!
update 1:
that looks promising, inmyth. give looking over. thanks!
private views cursortoview(cursor cursor) { views view = new views(); view.setmoduleid(cursor.getlong(0)); view.seteventid(cursor.getlong(1)); return view; }
update 2: answer
additionally had forgotten update allviewscolumn description column, not part of specific question, possibly out.
private views cursortoview(cursor cursor) { views view = new views(); view.setmoduleid(cursor.getlong(0)); view.seteventid(cursor.getlong(1)); view.setviewdescription(cursor.getstring(2)); return view; }
there go. didn't load description in cursortoview().
next time can read own database see if entry missing provided run emulator. how view data saved in android database(sqlite)?