2 slaks SLaks 于 2013.06.06 11:17 提问

数据库中不能存储 query

我运行下面的代码:

   mDb.beginTransaction();
        String updateQuery ="INSERT INTO MAAccounts(userId, accountId, accountType, accountName, parentAccountId, currencyCode, isTransactionDefaultStatusOpen, currentBalance, monthlyBudget, createdOn, updatedOn) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; 
    String[] valVars = { 
            stringToDB(account.userId),
            integerToDB(account.accountId).toString(),
            integerToDB(account.accountType.getValue()).toString(),
            stringToDB(account.accountName), 
            integerToDB(account.parentAccountId),
            stringToDB(account.currencyCode),
            boolToDB(account.isTransactionDefaultStatusOpen).toString(),
            CurrencyToDB(account.currentBalance).toString(),
            CurrencyToDB(account.monthlyBudget).toString(),
            dateToDB(now),
            "false"};
  //  Cursor c = mDb.rawQueryWithFactory(null, updateQuery, valVars, null);
    Cursor c = mDb.rawQuery(updateQuery, valVars);
    try{ 
        mDb.setTransactionSuccessful(); 
       }catch (Exception e){
           Log.e("Error in transaction", e.toString());
       }finally{
           mDb.endTransaction();
           c.close();
           }
        }

cursor 返回null,teh transaction 执行成功,但还是不能存储data 到数据库中。
Primary key 包括 UserId, accountId, 和 accountType。
没有异常记录。哪里出错呢?

Csdn user default icon
上传中...
上传图片
插入图片