1 | AB | BCD | ref | Ferari|
----------------------------------
1 | AB | BCD | ref | TOYOTA|
----------------------------------
1 | AB | BCD | ref| AUDI |
----------------------------------
1 | AB | BCD | ref| BMW |
---------------------------------
2 | BC | ABC | ref | NISSAN|
----------------------------------
2 | BC | ABC | ref | SUZKI|
----------------------------------
2 | BC | ABC | ref| TATA |
光标保存像这张表一样的数据。现在,我想得到像
getTopic = AB
getTitle= BCD
getType = ref
Names = FERARI TOYOTA AUDI BMW
我试过这个
do{
int current = cursor.getInt(cursor.getColumnIndexOrThrow("_id"));
String Title = cursor.getString(cursor.getColumnIndexOrThrow("TITLE"));
if(!StoreTitle.equalsIgnoreCase(Title) && lastId != current){
getTopic = cursor.getString(cursor.getColumnIndexOrThrow("TOPIC"));
getTitle = cursor.getString(cursor.getColumnIndexOrThrow("TITLE"));
getType = cursor.getString(cursor.getColumnIndexOrThrow("TYPE"));
getName = cursor.getString(cursor.getColumnIndexOrThrow("NAME"));
}else{
getName = getName +" "+ cursor.getString(cursor.getColumnIndexOrThrow("NAME"));
}
lastId = current;
StoreTitle = Title;
}while(cursor.moveToNext());
但是,它没有显示预期的结果。它正在显示BC
与Names
FERARI TOYOTA AUDI BMW 的专栏。
因为我也在检查lastitem!= currentitem
这个,它也没有显示最后的作者姓名。
现在,我的问题是
1)我应该怎么做才能得到预期的结果?2)由于我也在检查lastitem!= currentitem
这一点,它也没有显示最后的作者姓名。但是,我如何存储该名称。