I have a following table:
sdb.execSQL("create table if not exists userprofile (id integer primary key, profilename text, user text);");
I want to update profilename field in Android SQLite.
So I used the following code:
ContentValues cv= new ContentValues();
cv.put("user",et4.getText().toString());
String admin="user1";
sdb.update("userprofile", cv, "profilename = " + admin, null);
The table have profilename value as user1. But when I execute this I am getting
03-14 09:12:55.851: E/SQLiteLog(26616): (1) no such column: user1
Please help me to resolve the problem.
Thanks in advance.
Try to do it like this:
sdb.update("userprofile", cv, "profilename = ?", new String[] {"user1"});
I recommend this approach. Usage of placeholders solve problems like this. Your approach doesn't work because you are missing single quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With