I have a sqlite table called TermTable with the columns id, term and type:
static final String TermTable = "Terms"; static final String ID = "id"; static final String Term = "term"; static final String Type = "type"; 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:
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; } In another class I have invoked the insertTermList and inserted some for rows of values using a Datasource object called ds:
private void setData() { ds.insertTermList("abbey", "noun"); ds.insertTermList("abide", "verb"); ds.insertTermList("abound", "verb"); ds.insertTermList("absurd", "adjective"); } 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 text. How can I do that?
private void getData() { Cursor c = ??? if(c != null) { c.moveToFirst(); text.append(???); } } Any suggestions?