I’m developing an Android 3.1 Tablet which uses SQLite.
One table allows NULL values on a column. If I do the following and COLUMN_ARTICLE_QUANTITY_GOODS_NON_PACKET is NULL, c.getLong returns 0 and I want to get NULL instead of 0.
int goodsNonPckIdx =
c.getColumnIndex(SqlConstants.COLUMN_ARTICLE_QUANTITY_GOODS_NON_PACKET);
articleQty.setGoodsNonPacket(c.getLong(goodsNonPckIdx));
By the way GoodsNonPacket is a Long (an object).
How can I get null values from database?
c.getLong(goodsNonPckIdx)will always return along(primitive data type) value which can’t benull.You can probably use the isNull method to check if it is null or not and set the value based on that.