Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – Cursor.moveToNext()返回false,而Cursor.getCount()表示超过1行大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的sqlite DB中运行查询..

我将结果保存在我的cursor中,并且我正在迭代它以获得所有结果..

allotugh我正在检查并看到光标有超过1行,它只给我第一行,因为moveToNext()总是返回false.

这是我的迭代代码

@H_502_17@cursor cursor = getEventsDetails(db,SELEction,null); Log.e("cursor before","count" + cursor.getCount()); Boolean moveToNext = cursor.moveToFirst(); if (moveToNext) { do { //Create a new PicoEvent instance with the event's details PicoEvent event = PicoEventCreator.createPicoEvent(cursor); Log.e(event.getName(),event.getStartTime().toLocaleString()); Log.e("cursor in","count" + cursor.getCount()); moveToNext = cursor.moveToNext(); Log.e("moveToNext","move: " + moveToNext); if (!isEventexists(eventsList,event)) eventsList.add(event); } while (moveToNext); }

这是Logcat调试:

@H_502_17@12-01 17:33:07.774: E/cursor before(5950): count4 12-01 17:33:08.094: E/Pico Demo Event(5950): 1 בדצמ 2013 11:00:00 12-01 17:33:08.124: E/cursor in(5950): count4 12-01 17:33:08.124: E/moveToNext(5950): move: false

正如你所看到的行数是4,但这一举动是错误的……

解决方法

您正在将此cursor传递给此调用中的另一个方法

@H_502_17@PicoEvent event = PicoEventCreator.createPicoEvent(cursor);

我敢打赌,该方法是在光标返回之前将光标推进到最后.

大佬总结

以上是大佬教程为你收集整理的android – Cursor.moveToNext()返回false,而Cursor.getCount()表示超过1行全部内容,希望文章能够帮你解决android – Cursor.moveToNext()返回false,而Cursor.getCount()表示超过1行所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。