Sebastian Sebastian - 1 month ago 16
Java Question

multiple value to listview

public ArrayList<String> getAllCotacts() {
ArrayList<String> array_list = new ArrayList<>();

//hp = new HashMap();
SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery("select * from contacts", null);
res.moveToFirst();

while (!res.isAfterLast()) {
array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_NAME)));
res.moveToNext();
}
return array_list;
}
}


it only displaying name on listview... there is an e mail field.. how can i display that too

Tom Tom
Answer

Use this code...

while(!res.isAfterLast()){
        array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_NAME)) +"\n"+res.getString(res.getColumnIndex(CONTACTS_COLUMN_EMAIL)));
        res.moveToNext();
    }
Comments