title: Android how to get values from columns in a sqlite database
body: <p>I have a sqlite table called <b>TermTable</b> with the columns <i>id</i>, <i>term</i> and <i>type</i>:</p>
  
  <pre><code>static final String TermTable = "Terms";
  static final String ID = "id";
  static final String Term = "term";
  static final String Type = "type";
  </code></pre>
  
  <p>Also, I have a Datasource class that implements the db and have the following methods to put and get data in and out of table:</p>
  
  <pre><code>public long insertTermList(String term, String type) {
  
      ContentValues initialValues = new ContentValues();
  
      initialValues.put(WordsDB.Term, term);
      initialValues.put(WordsDB.Type, type);
  
      return db.insert(WordsDB.TermTable, null, initialValues);
  }
  
  public Cursor getTermValues(int index) {
  
      String from[] = { "Term", "Type" };
      String where = WordsDB.ID + "=" + index;
      Cursor cursor = db.query(true, WordsDB.TermTable, from, where, null, null, null, null, null);
      return cursor;
  }
  </code></pre>
  
  <p>In another class I have invoked the insertTermList and inserted some for rows of values using a Datasource object called <b>ds</b>:</p>
  
  <pre><code>private void setData()
  {
      ds.insertTermList("abbey", "noun");
      ds.insertTermList("abide", "verb");
      ds.insertTermList("abound", "verb");
      ds.insertTermList("absurd", "adjective");
  }
  </code></pre>
  
  <p>Now I want to get values from the columns according to the id I give it and append each column value of each row to a text view called <b>text</b>. How can I do that?</p>
  
  <pre><code>private void getData() {
  
      Cursor c = ???
  
      if(c != null)
      {
          c.moveToFirst();
          text.append(???);
      }
  }
  </code></pre>
  
  <p>Any suggestions?</p>