cursor.getType() and CursorIndexOutOfBoundsException exception

匆匆过客 提交于 2019-12-07 09:33:40

问题


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


回答1:


It's because SQLite uses dynamic typing:

Most SQL database engines (every SQL database engine other than SQLite, as far as we know) uses static, rigid typing. With static typing, the datatype of a value is determined by its container - the particular column in which the value is stored.

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

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

So no value, no data type.



来源:https://stackoverflow.com/questions/8133784/cursor-gettype-and-cursorindexoutofboundsexception-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!