简体   繁体   中英

Android Sqlite - Updating a table for a string

I have a simple question : I'm new to sql so i have this question :

The below method works if names is a number. How to write this query if names is a string?

ourDatabase.update(DATABASE_TABLE, cv , KEY_NAME + "=" + names, null);

String literals in SQL are quoted in 'single quotes' .

Though it's preferable to use ? literal placeholders and bind arguments here, eg

ourDatabase.update(DATABASE_TABLE, cv, KEY_NAME + "=?", new String[]{names} );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM