title: Android & SQLite : how to display the multiple column value
body: <p>i hope you guys can help to solve my problem.</p>
  
  <p>my problem is cant retrieve the multiple value of column. In my database contain 4 columns (id, namaStation, ticket, masa). right now the program only displayed value of namaStation. It mybe because of the toString() method in Comment class because its only return 1 value (namaStation). can help me??</p>
  
  <h2>This is my program. ##</h2>
  
  <h3>1. Call the query.</h3>
  
  <p>`public void onClick(View view) {</p>
  
  <pre><code>    @SuppressWarnings("unchecked")
      ArrayAdapter&lt;Comment&gt; adapter = (ArrayAdapter&lt;Comment&gt;) getListAdapter();
      Comment comment = null;
  
      switch (view.getId()) {
      case R.id.add:
  
          List&lt;Comment&gt; values = datasource.query("Kelana Jaya");
  
          adapter = new ArrayAdapter&lt;Comment&gt;(this, android.R.layout.simple_list_item_1, values);
          setListAdapter(adapter);
  
          break;`
  </code></pre>
  
  <h3>2. The query.</h3>
  
  <pre><code>    @SuppressWarnings("static-access")
  public List&lt;Comment&gt; query(String namaStation){
  
      //List&lt;Comment&gt; comments = new ArrayList&lt;Comment&gt;();
  database = dbHelper.getReadableDatabase();
      List&lt;Comment&gt; comments = new ArrayList&lt;Comment&gt;();
  
      Cursor cursor = database.query(MySQLiteHelper.TABLE_COMMENTS,
              allColumns,  MySQLiteHelper.COLUMN_namaStation+"=?",new String[]{namaStation}, null, null, null);
      cursor.moveToFirst();
      while (!cursor.isAfterLast()) {
      //  Comment comment = cursorToComment(cursor);
  
          Comment comment = new Comment();
          comment.setId(cursor.getLong(0));
          comment.setNamaStation(cursor.getString(1));
          comments.add(comment);
          comment.setTicket(cursor.getString(2));
          comments.add(comment);
          cursor.moveToNext();
      }
      // Make sure to close the cursor
      cursor.close();
      return comments;
  </code></pre>
  
  <h3>3. The Comment class</h3>
  
  <pre><code>public class Comment {
  private long id;
  public String namaStation;
  public String ticket;
  public String masa;
  public String comment;
  public int x;
  
  
  public Comment(){
  
  
  
  }
  public Comment(long id, String namaStation, String ticket, String masa){
  
      this.id=id;
      this.namaStation=namaStation;
      this.ticket=ticket;
      this.masa=masa;
  
  }
  public long getId() {
      return id;
  }
  
  public void setId(long id) {
      this.id = id;
  
  }
  
  public String getNamaStation() {
      return namaStation;
  
  }
  
  public void setNamaStation(String comment) {
      this.namaStation = comment;
  
  
  }
  
  
  public String getTicket() {
      return ticket;
  }
  
  public void setTicket(String comment) {
      this.ticket = comment;
  
  }
  
  public String getMasa() {
      return masa;
  }
  
  public void setMasa(String comment) {
      this.masa= comment;
  }
  // Will be used by the ArrayAdapter in the ListView
  public String toString() {
  
      return ticket;
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <h3>The display (the layout is not in proper way because im not setup its yet.. :) )</h3>
  
  <p><a href="http://i.stack.imgur.com/OW2pz.png" rel="nofollow">the display</a></p>