Does A Cursor In Android Reference Columns From 0 Or 1?
Solution 1:
A cursor from a SQLite database in Android references columns from 0.
Solution 2:
I have no idea how you searched in Google, but from the official documentation of Android Cursor
public abstract int getColumnIndex (String columnName) Since: API Level 1
Returns the zero-based index for the given column name, or -1 if the column doesn't exist. If you expect the column to exist use getColumnIndexOrThrow(String) instead, which will make the error more clear. Parameters columnName the name of the target column. Returns
the zero-based column index for the given column name, or -1 if the column name does not exist.
And you were really not able to find that, but a bunch of useless stuff?
Solution 3:
The Android documentation states that the getColumnIndex method from a SQLite Cursor returns the zero-based index for the given column name, or -1 if the column doesn't exist.
If you expect the column to exist use getColumnIndexOrThrow(String) instead, which will make the error more clear.
In short, they start at 0.
Source:
Post a Comment for "Does A Cursor In Android Reference Columns From 0 Or 1?"