cursor.getLong(1) 没有抛出异常
cursor.getLong(1) not throwing Exception
我在数据库中有一个空字段
当我在游标中检索它时,它为空。
我可以从
cursor.isNull(1) is true
So when I do cursor.getLong(1) it should throw an exception according to the documentation. but it actually retrieves 0 without and exception.
any ideas why?
如果你看一下 MatrixCursor 中方法 getLong()
的实现,你可以看到下面的代码:
@Override
public long getLong(int column) {
Object value = get(column);
if (value == null) return 0;
if (value instanceof Number) return ((Number) value).longValue();
return Long.parseLong(value.toString());
}
如果值为空,则返回 0。
我在数据库中有一个空字段 当我在游标中检索它时,它为空。 我可以从
cursor.isNull(1) is true So when I do cursor.getLong(1) it should throw an exception according to the documentation. but it actually retrieves 0 without and exception. any ideas why?
如果你看一下 MatrixCursor 中方法 getLong()
的实现,你可以看到下面的代码:
@Override
public long getLong(int column) {
Object value = get(column);
if (value == null) return 0;
if (value instanceof Number) return ((Number) value).longValue();
return Long.parseLong(value.toString());
}
如果值为空,则返回 0。