Table fields:
_id, street, house_nr
query:
mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_STREET_NAME,
KEY_HOUSE_NUMBER}, null, null, null, null, KEY_ROWID + " DESC");
SimpleCursorAdapter:
Cursor c = mDbHelper.fetchAllRows();
startManagingCursor(c);
String[] from = new String[] { HistoryDbAdapter.KEY_STREET_NAME};
int[] to = new int[] { R.id.text1 };
SimpleCursorAdapter entries =
new SimpleCursorAdapter(this, R.layout.history_row, c, from, to);
setListAdapter(entries);
How to add one combined string from two db fields into R.id.text1 to show full address.
example:
street = "Android street"
house_nr = "911"
then:
R.id.text1 = "Android street 911"
thanks
There are two ways:
Concat both column names in the query: KEY_STREET_NAME + ” || ” + KEY_HOUSE_NUMBER. I would use a rawQuery then.
Use a custom adapter.