1

I have an SQL Update statement like:

UPDATE table set column = column+1

Is it possible to do someting similiar with ContentValues?

ContentValues values = new ContentValues();

values.put("colum", ?);

1
  • I am not sure, but I think you could do this, try incrementing it Commented Apr 17, 2015 at 6:22

1 Answer 1

3

Is it possible to do someting similiar with ContentValues?

No. You can only put literals in ContentValues, not expressions.

Under the hood the values in ContentValues get translated to sqlite3_bind...() calls and sqlite3 parameter binding only supports replacing literals with parameters.

To use an expression, just use execSQL() with the raw SQL you have.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, its a little bit sad, because i wantet to do something like if update()<1 then insert(), but then i have to split it into different commands

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.