Java 在Android的SQlite数据库中存储Null

Java 在Android的SQlite数据库中存储Null,java,android,eclipse,sqlite,Java,Android,Eclipse,Sqlite,我正在尝试实现以下代码 String updateQuery ="INSERT INTO MAAccounts(userId, accountId, accountType, accountName, parentAccountId ) VALUES(?, ?, ?, ?, ?)"; Cursor c = mDb.rawQuery(updateQuery, new String[]{ stringToDB(account.userId),

我正在尝试实现以下代码

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(),
                });
现在parentAccouId(int类型)的初始值为null。它实际上正在将null转换为.String

当我尝试运行时,它给出了空指针的错误

我想在数据库中存储空值,请告诉我怎么做


致以最诚挚的问候

为什么不检测一下它是否为空呢。如果为空,则将“空”插入数据库。

使用:

account.parentAccountId != null ? 
  integerToDB(account.parentAccountId).toString() : "null"

好的,我这样做了,但现在它说索引4处的bind值为null。有什么想法吗?