我想从数据库中获取ID和partyname并返回两者,并希望显示listitem,但是点击后的listitem ID应该传递给另一个活动,而不是partyname,快照:" {{3} }&#34 ;.
public ArrayList<String> getPartyName(){
ArrayList<String> partylist = new ArrayList<String>();
SQLiteDatabase db = this.getDB();
Cursor c;
try {
c = db.rawQuery("SELECT * FROM RECORDS" , null);
if(c == null) return null;
String PARTY_NAME;
c.moveToFirst();
do {
PARTY_NAME = c.getString(3);
partylist.add(PARTY_NAME);
[![enter image description here][1]][1]
} while (c.moveToNext());
c.close();
db.close();
} catch (Exception e) {
Log.e("login", e.getMessage());
}
return partylist;
}
答案 0 :(得分:0)
更改您的查询:
c = db.rawQuery("SELECT id FROM RECORDS" , null);
将id替换为您的id列的名称。