开发者

Android - SQlite - Store null into a double field?

I am storing a double into a sqlite database. This value can be null, and I need to know whether the value is 0 or null.

Is it possible to ach开发者_如何学Pythonieve this?

//grade is a type double in database
Double myValue =  cursor.getDouble(cursor.getColumnIndex("grade"));


To check for null use 'isNull(...)'...

Double myValue;
if (!cursor.isNull(cursor.getColumnIndex("grade"))
    myValue =  cursor.getDouble(cursor.getColumnIndex("grade"));
else
    // Handle null scenario


You could store it as a string and parse it on the way in and out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜