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) != null ? integerToDB(account.parentAccountId).toString() : null),
stringToDB(account.currencyCode),
boolToDB(account.isTransactionDefaultStatusOpen).toString(),
CurrencyToDB(account.currentBalance).toString(),
CurrencyToDB(account.monthlyBudget).toString(),
dateToDB(now),
"false"};
Cursor c = mDb.rawQuery(updateQuery, valVars);
Guys i am getting error , java.lang.IllegalArgumentException: the bind value at index 4 is null
Any help will be appreciated
This error comes when you are firing some query with
where clauseorany other conditionwith value asnull.Example-
select * from tbl_name where _id = nullwhere as it should be
select * from tbl_name where _id = some_idSo debug and check that when your query is fired you have all your values that are used in building your query.
In your case it seems that this line,
is returning
nullso check this value.