I’m trying to understand why they would start the cursor before the first position in a row and why it would end after the last position. Is there an inherit advantage to doing it this way?
For example:
public abstract int getPosition ()Since: API Level 1
Returns the current position of the cursor in the row set. The value is zero-based. When the row set is first returned the cursor will be at position -1, which is before the first row. After the last row is returned another call to
next()
will leave the cursor past the last entry, at a position of
count().returns
the current cursor position.
Thank you.
Because a
Cursorisn’t guaranteed to be populated with rows. If you got aCursorback from a database with 0 rows, the initial position being at 0 doesn’t make sense since there isn’t a row at position 0.