0

everyone. This is a piece of code from using sqlite in android tutorial:

return db.update(employeeTable, cv, colID+"=?", 
new String []{String.valueOf(emp.getID())});  

I don't understand why in colID+"=?" after '=' stay '?'

Anyone can explain this, please?

Thanks for everyone!

1

3 Answers 3

1

This is a Prepared Satatement. In this case, you can define a query as a template and left some parameters to fill dynamically. You represent the parameter with an ?. In your case, you are indicating that String.valueOf(emp.getID()) will substitute the ?.

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

Comments

1

This is parametrized statement, this mean that this String.valueOf(emp.getID()) will be added intead of ? character. ? represents one argument and String[] represents data which will be added to where clause.

Comments

1

The ? is where your argument is substituted into the query. Your argument in this case is String.valueOf(emp.getID().

Comments

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.