0

我的应用程序中有一个 Sql lite 表。

我想添加一个游标来解析表格,使其从当前位置向前移动。
主要思想是更新所有下一行而不是前一行。

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

4

1 回答 1

2
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不为空,然后逐行遍历每一行,直到到达最后一行。完成后,我调用close().cursor

于 2015-04-24T16:54:33.560 回答