android - I'm getting object data output from sqlite instead of the data I need -


i'm getting object data returned code here, don't see how can doing that.

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_manage);      log.d(tag, "oncreate");      datasource = new datasource(this);     datasource.open();      list<encouragement> values = datasource.getallencouragements();      log.d(tag, "values");      arrayadapter<encouragement> adapter = new arrayadapter<encouragement>(this,         android.r.layout.simple_list_item_1, values);      setlistadapter(adapter);     log.d(tag, "end of oncreate"); } 

and

public list<encouragement> getallencouragements() {      list<encouragement> encouragements = new arraylist<encouragement>();      cursor cursor = database.query(databasehelper.table_encouragements,             allcolumns, null, null, null, null, null);      cursor.movetofirst();      while (!cursor.isafterlast()) {         encouragement encouragement = cursortoencouragement(cursor);         encouragements.add(encouragement);         cursor.movetonext();     }      cursor.close();     return encouragements; } 

is producing com.example.myactivity.myobject@34563475 in list item.

the listview calling tostring() represent myobject. have not overridden tostring() method hence default object.tostring() method called.

@override public string tostring(){    return this.name; // whatever need represent instance of myobject. } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -