1
public class Profile implements Parcelable {

public final static String ACCOUNTS_TABLE_NAME = "accounts";
public final static String FIELD_DISPLAY_NAME = "displayname";
public final static String FIELD_IP = "ipaddress";
}



String f1 = "planet";
String ip = "udp:85.59.123.78:289";

My update query is like below

db.execSQL("UPDATE " + Profile.ACCOUNTS_TABLE_NAME + " SET " + SipProfile.FIELD_IP+ "="+ip +" WHERE "+ Profile.FIELD_DISPLAY_NAME + "=" + f1);

i am getting below error

03-14 09:28:59.720: E/SQLiteLog(13321): (1) near ":85": syntax error

1
  • 1
    Well, first, you're using concatenation to create SQL and are therefore quite possibly risking injection attacks and so on. But besides that, you aren't quote-delimiting the IP address. Commented Mar 14, 2015 at 4:27

1 Answer 1

1

Use this, in where clause ip and f1 values should be in single quotes

db.execSQL("UPDATE " + Profile.ACCOUNTS_TABLE_NAME + " SET " + SipProfile.FIELD_IP+ "='"+ip +"' WHERE "+ Profile.FIELD_DISPLAY_NAME + "='" + f1+"'");
Sign up to request clarification or add additional context in comments.

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.