Exception cursor.getType () and CursorIndexOutOfBoundsException

There is something that I cannot understand about Cursor.getType() , can anyone explain why I get this stupid exception when I want to get the column type if the cursor has no record but there are columns? I mean, if the cursor has a record, there is no problem, I can use the getType method to get the column type without any problems, but if there is no record, this throws this exception. The question is, why do I need records to get the type of columns? Why just knowing the column name is not enough to get its types? This is ridiculous?

+4
source share
1 answer

This is because SQLite uses dynamic typing:

Most of the SQL DBMS mechanisms (each SQL database engine other than SQLite, as far as we know) use static, strong typing. With static typing, the data type of a value is determined by its container β€” the specific column in which the value is stored.

SQLite uses a more general dynamic type system. In SQLite, the value data type is associated with the value itself, and not with its container.

http://www.sqlite.org/datatype3.html

So no value, no data type.

+9
source

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


All Articles