在 SQlite 数据库中存储 Null

我想实现下面的代码:

String updateQuery ="INSERT INTO MAAccounts(userId, accountId, accountType, accountName, parentAccountId ) VALUES(?, ?, ?, ?, ?)"; 


        Cursor c = mDb.rawQuery(updateQuery, new String[]{
                stringToDB(account.userId),
                integerToDB(account.accountId).toString(),
                integerToDB(account.accountType.getValue()).toString(),
                stringToDB(account.accountName),
                integerToDB(account.parentAccountId).toString(),
                });

现在 parentAccoudId (Type int )的初始值是 null。实际上是把null转化为 to.String。
当我运行它时,给出空指针的错误。
我想在数据库中存储null值,如何实现?

你可以使用android 提供的insert语句,使用
ContentValues values = new ContentValues();
values.put("key", Object);
的方式,你就不用关心Object是否为空的情况了,
或者你自己手动判断下Object是否为null,不等于null的情况在调用toString(),否则直接赋值null.

数据库中的一条记录,如果某列没有值, 那么其实就是null