java - Android SQLite getContact issue -


hey guys i've done tutorial: http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/

and found useful doesn't go on how use 'db.getcontact()'.

here code in handler calling it:

// getting single contact contact getcontact(int id) {     sqlitedatabase db = this.getreadabledatabase();      cursor cursor = db.query(table_contacts, new string[] { key_id,             key_name }, key_id + "=?",             new string[] { string.valueof(id) }, null, null, null, null);     if (cursor != null)         cursor.movetofirst();      contact contact = new contact(integer.parseint(cursor.getstring(0)),             cursor.getstring(1));     // return contact     return contact; } 

and i'm attemping call by:

callbutton.setonclicklistener(new view.onclicklistener() {                   @override         public void onclick(view v) {             edittext edittext = (edittext)findviewbyid(r.id.edittext2);             int id = integer.parseint(edittext.gettext().tostring());              string name = db.getcontact(id);             //do              }         }                }); 

what right syntax calling , returning need, i've tried lot of different ways don't understand it. thanks

contact cn = db.getcontact(id); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -