Is there a cursor in Android link columns from 0 or 1?

I am working with SQLite Database and I am returning cursors successfully, but I was wondering if the cursor refers to columns starting at 0 as arrays or only 1?

+4
source share
3 answers

The cursor from the SQLite database in Android refers to columns with 0.

+12
source

I have no idea how you searched on Google, but from the official Android Cursor documentation

public abstract int getColumnIndex (String columnName) Because: API Level 1

Returns a zero-based index for the given column name, or -1 if the column does not exist. If you expect the column to exist, use getColumnIndexOrThrow (String), which will make the error more Pure. Parameters columnName is the name of the target column. Returns

column index with a null value for the column name, or -1 if the column name does not exist.

And you really could not find it, but a bunch of useless things?

+4
source

The Android documentation states that the getColumnIndex method from SQLite Cursor returns an index with a null value for a given column name, or -1 if the column does not exist.

If you expect the column to exist, use getColumnIndexOrThrow (String) instead, which will make the error more understandable.

In short, they start at 0.

A source:

http://developer.android.com/reference/android/database/sqlite/SQLiteCursor.html#getColumnIndex(java.lang.String )

+1
source

Source: https://habr.com/ru/post/1402323/


All Articles