Java游标只提供50行

时间:2014-11-04 14:19:36

标签: java android sqlite

我正在使用此光标但面临问题

它只返回50行,而数据库表有500多行,它从第49条记录后的while循环中输出

Cursor c = db.rawQuery("select * FROM mytable order by id", null);
Toast.makeText(this, "Row count---"+c.getCount(), Toast.LENGTH_SHORT).show();//giving 500 record
int ik= 0;
if (c != null ) {
while (c.moveToNext()) {
    ik++;
    Toast.makeText(this, " increment---"+ik, Toast.LENGTH_SHORT).show();//count upto only 49
}
}

请帮助

try catch没有错误 但是在第49条记录之后,它发送连接到wifi的请求,而我没有使用任何wifi启用设置

是否有其他方法可以获取所有记录。

提前致谢

1 个答案:

答案 0 :(得分:1)

只是一件事,我想:

Cursor c = db.rawQuery("select * FROM mytable order by id", null);
Toast.makeText(this, "Row count---"+c.getCount(), Toast.LENGTH_SHORT).show();//giving 500 record
int ik= 0;
if (c.moveToFirst()) {
    do {
        ik++;
        Log.i("CursorCheck", " increment---"+ik);//should count until the last one
    } while(c.moveToNext())
}

注意c.moveToFirst()。否则,光标可能在任何不方便的地方。这样你就可以确保从一开始就得到它们。

我还将检查更改为使用日志,否则,有500个Toasts可能会耗尽