statement and method to update sqlite database -


i need please. i've spent way time on , can update database if specify id number.

  1. click listview item , send data new activity editing
  2. edit data , return listview activity. simple right. hmmm.

    @override   public void onitemclick(adapterview<?> listview, view view, int position, long id) {     cursor cursor = (cursor)listview.getitematposition(position);   string title = cursor.getstring(cursor.getcolumnindexorthrow(moviesdbadapter.key_title));   string barcode = cursor.getstring(cursor.getcolumnindexorthrow(moviesdbadapter.key_barcode));    string rowid = cursor.getstring(cursor.getcolumnindexorthrow(moviesdbadapter.key_rowid));  intent movieedit = new intent(getbasecontext(), movieedit.class);   bundle bundle = new bundle();   bundle.putstring("rowid", rowid);   bundle.putstring("title", title);   bundle.putstring("barcode", barcode);   movieedit.putextras(bundle);   startactivity(movieedit); 

receive intent listview activity:

if (this.getintent().getextras() != null) {  bundle bundle = this.getintent().getextras();             edittitle.settext(bundle.getstring("title"));                 editbarcode.settext(bundle.getstring("barcode"));            editid.settext(bundle.getstring("rowid"));            }  

the statement activated button:

case r.id.buttonsave:  mdb.open();   contentvalues values = new contentvalues();   values.put(moviesdbadapter.key_title, title);   values.put(moviesdbadapter.key_barcode, barcode);   mdb.updatetitle("=?", title, barcode);   mdb.close();  

the method in moviedbadapter:

public boolean updatetitle(long rowid, string title, string barcode) {   contentvalues args = new contentvalues();   args.put(key_title, title);   args.put(key_barcode, barcode);    return mdb.update(sqlite_table, args, key_rowid + "=" + rowid, null) > 0; 

i know has been done death no matter try can't update database new data. hope can guys.

change code following

case r.id.buttonsave:      mdb.open();       mdb.updatetitle(rowid, title, barcode);       mdb.close();  

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -