Skip to content Skip to sidebar Skip to footer

Android : Sqlite Error - (1) Near "null": Syntax Error

I'am getting data from the server as a JSONObject and am saving to my table. I'am facing the following error. 11-22 02:18:35.489: E/AndroidRuntime(2597): android.database.sqlite.S

Solution 1:

As mentioned, you need to assign values to the public static Strings in the ContactDB class. You should also make them final, to prevent them from being accidentally modified.

public static final String con_id = "con_id";
public static final String short_name = "short_name";
public static final String first_name = "first_name";
public static final String last_name = "last_name";
public static final String pid = "pid";
public static final String cid = "cid";
public static final String number = "number";   

Solution 2:

public static String CREATE_QUERY = "create table "+TABLE_NAME+" ("+con_id+" INTEGER PRIMARY KEY AUTOINCREMENT, "+short_name+" TEXT, "+first_name+" TEXT, "+last_name+" TEXT, "+pid+" TEXT, "+cid+" TEXT, "+number+" TEXT);";

your con_id is gettint null value. you can use hard coded string like "id"


Post a Comment for "Android : Sqlite Error - (1) Near "null": Syntax Error"