Does a cursor in Android reference columns from 0 or 1?

后端 未结 3 1964
粉色の甜心
粉色の甜心 2021-01-18 03:50

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?

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-18 04:47

    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?

提交回复
热议问题