android database cursor missing common methods such as
getBoolean
getDate
getObject
getBigDecimal
Why is that?
How to implement these methods? Should I call getString(index) then convert it to the type above? How about getObject()?
Primarily because they are not needed and some are also not portable.
- Boolean just use an INTEGER with 0 or 1, you could use masks to have multiple booleans if wanted.
- Date use INTEGER (getLong) or TEXT or REAL.
- Object can potentially be saved as bytes (BLOB) or split into it's components. Noting as an example, that an object in Java, would not be readable/usable in C++, which would then very much contravene portability.
- BigDecimal use REAL (getDouble/getFloat), TEXT or even bytes (BLOB).
Have a read of Datatypes In SQLite Version 3 which explains the flexibility of SQLite and Data types.