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.
精彩评论