I am working with an SQLite Database and I am returning cursors successfully but I was wondering if a cursor references columns starting with 0 like arrays or just 1?
A cursor from a SQLite database in Android references columns from 0.
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?
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:
http://developer.android.com/reference/android/database/sqlite/SQLiteCursor.html#getColumnIndex(java.lang.String)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With