向前移动 android sql lite 游标

Moving android sql lite cursor forward

我的应用程序中有一个 Sql 精简版 table。

我想添加一个游标来解析 table 以便它从当前位置向前移动。
主要思想是更新所有下一行而不是上一行。

如果需要,任何人都可以给我一个示例光标来处理任何循环吗?

if (cursor.moveToFirst()) { //Replace this with cursor.moveToPosition(position) to iterate from that position to the end of your cursor, rather than from start to finish.
    while (!cursor.isAfterLast()){
          cursor.getInt(0); //get whatever information you require.
          cursor.moveToNext();
    }
    if (!cursor.isClosed()) {
        cursor.close();
    }
}

有很多方法可以实现这一点。在上面的示例中,我首先检查以确保 cursor 不为空,然后逐行检查每一行,直到到达最后一行。完成后,我在 cursor 上调用 close()