Is Android Cursor.moveToNext() Documentation Correct?

后端 未结 5 1923
春和景丽
春和景丽 2021-01-12 03:00

boolean android.database.Cursor.moveToNext() documentation says:

http://developer.android.com/reference/android/database/Cursor.html#moveToNext%28%29

Move th

5条回答
  •  攒了一身酷
    2021-01-12 03:34

    Verbatim from the API:

    Returns: whether the move succeeded.


    So, it means that:

    Cursor in first row -> moveToNext() -> cursor in second row -> there's no second row -> return false


    If you want the details, go to the source: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.3_r1/android/database/AbstractCursor.java#AbstractCursor.moveToNext%28%29

    public final boolean moveToNext() {
      return moveToPosition(mPos + 1);
    }
    
    public final boolean moveToPosition(int position) {
        // Make sure position isn't past the end of the cursor
        final int count = getCount();
        if (position >= count) {
            mPos = count;
            return false;
        }
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题