Currently, the update function in SQLiteDatabase uses String[] for the Where args.
update(String table, ContentValues values, String whereClause, String[] whereArgs)
I find this very strange
A) Normally values are passed using the ContentValues object: I can pass the actual object and SQLiteDatabase will convert it properly using its native binding functions.
For Example I can put in the Content Value a Long and SQLiteDatabase will convert it properly during the insertion.
put(String key, Long value)
B) However, for the Where Condition, I need to actually convert the values in to String by myself. Of course in the majority of the cases this is not problem as a .toString() will do the job. However in some cases the conversion is not so straight forward, for example:
- to covert a Float number, shall I use "." or "," as decimal point (this varies countries to countries)?
- how do I convert to String the null value?
QUESTIONS:
Question 1) Do you have any suggestions on the best practice to use the Where Statement?
Question 2) Is there a way to pass the whereArgs as ContentValues in order to use native binding for the conversion?
Question 3) If I will use String[] as whereArgs, I will come to a not aligned situation: the insertion itself uses the native binding functions, but the where statement needs a conversion by myself. I feel this will my generate some conflicts (eg. I insert the float "5.2" but then later I update the line searching by "5,2").
Questions 3.1) Has someone even had similar problems and what was the solution?
Questions 3.2) In order to align the 2 kind of conversions, I was thinking to take care always to the conversion to String: so to pass to ConcentValues only String (converted by me) + of course to use the same conversion for the String[] WhereArgs. Would this be a solution? What are the disadvantages you can foreseen?
Thanks in advance to all of you for your support Enrico