我的 List<String>
有问题
List<String> werte = new LinkedList<String>();
if(c.moveToNext()){
werte.add(c.getString(c.getColumnIndex("fragencount")));
}
String size = "" +werte.size();
tv.setText(size);
我想将光标中的字符串添加到 LinkedList<String>()
中.当我尝试 c.getCount()
,我得到 13。
当我尝试读取 LinkedList
的大小时,我得到 0。我不明白为什么。
最佳答案
使用 do-while
添加 LinkedList 中的所有值
LinkedList<String> werte = new LinkedList<String>();
if(c.moveToFirst())
{
do
{
werte.add(c.getString(c.getColumnIndex("fragencount")));
}while(c.moveToNext());
}
c.close();
String size = "" +werte.size();
tv.setText(size);
关于java - 游标的空列表问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14525980/