Proper syntax for updating a row in Android with SQLite -


ok, have 2 android projects both running same api level. in one, update sqlite row using:

db.update(database_table, updatevalues, key_rowid + "=" + rowid, null); 

in other using:

db.update(database_table, updatevalues, field_collection_id + "=?", new string[] {collectionid}); 

they both work. except in second project, if change syntax match first one, (i.e. remove question mark clause , set whereargs null), returns 0 rows affected. there reason this? im thinking of sticking second syntax because apparently reduces possibility of sql injection thought throw 1 out there , see if had similar experience.

also interesting documentation doesn't specify whereargs for, there: sqlitedatabase:update()

when remove question mark, replacing value of collectionid?

the second syntax means sqlite can reuse same cached copy of query number of different values of rowid or collectionid, rather having different query each time it's invoked. saves lots of resources.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -