Note that there are some explanatory texts on larger screens.

plurals
  1. POSQLite syntax error: while compiling: UPDATE contacts SET name=? WHERE phone=+34
    text
    copied!<p>In my project, there's a peace of code that is waiting to be called by ContentObserver when there's a change on the contact table. When it happens, i check every contact in the table one by one if had been changed or one had been created. Then depending on this I save my changes on my own table. But it gives me errors. There's my code:</p> <pre><code>while (phones.moveToNext()) { try { name = phones .getString(phones .getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); phoneNumber = phones .getString(phones .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); JSONObject jobject = db.select_contact(name, phoneNumber); String type1 = jobject.getString("type"); if (type1.equals("upload")) { Log.i("********", "Upload on the db" + name + " " + phoneNumber); db.contact_table(name, phoneNumber); } else if (type1.equals("change_name")) { db.update_name(name, phoneNumber); Log.i("********", "Change name and upload " + name); } else if (type1.equals("change_phone")) { db.update_name(name, phoneNumber); Log.i("********", "Change phone and upload " + phoneNumber); } } catch (Exception ex) { ex.printStackTrace(); } } </code></pre> <p>And there's the part where i upload it to my own table created by me:</p> <pre><code>public long update_name(String name, String number) { ContentValues cv = new ContentValues(); cv.put(NAME, name); return ourDatabase.update(DATABASE_TABLE_4, cv, NUMBER + "=" + number, null); } public long update_number(String name, String number) { ContentValues cv = new ContentValues(); cv.put(NUMBER, number); return ourDatabase .update(DATABASE_TABLE_4, cv, NAME + "=" + name, null); } </code></pre> <p>The problem is that on the part of upload changes on the DB, it gives me this errors:</p> <blockquote> <p>07-07 09:28:41.412: W/System.err(11667): android.database.sqlite.SQLiteException: near "629": syntax error: , while compiling: UPDATE contacts SET name=? WHERE phone=+34 629 21 00 80 07-07 09:28:41.412: W/System.err(11667): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) 07-07 09:28:41.412: W/System.err(11667): at android.database.sqlite.SQLiteCompiledSql.(SQLiteCompiledSql.java:68) 07-07 09:28:41.412: W/System.err(11667): at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:143) 07-07 09:28:41.412: W/System.err(11667): at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361) 07-07 09:28:41.412: W/System.err(11667): at android.database.sqlite.SQLiteStatement.acquireAndLock(SQLiteStatement.java:260) 07-07 09:28:41.412: W/System.err(11667): at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:84) 07-07 09:28:41.412: W/System.err(11667): at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1936) 07-07 09:28:41.412: W/System.err(11667): at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1887) 07-07 09:28:41.412: W/System.err(11667): at com.background.Database.update_name(Database.java:215) 07-07 09:28:41.417: W/System.err(11667): at com.extract.Contacts.onChange(Contacts.java:69) 07-07 09:28:41.417: W/System.err(11667): at android.database.ContentObserver$NotificationRunnable.run(ContentObserver.java:43) 07-07 09:28:41.417: W/System.err(11667): at android.os.Handler.handleCallback(Handler.java:605) 07-07 09:28:41.417: W/System.err(11667): at android.os.Handler.dispatchMessage(Handler.java:92) 07-07 09:28:41.417: W/System.err(11667): at android.os.Looper.loop(Looper.java:137) 07-07 09:28:41.417: W/System.err(11667): at android.app.ActivityThread.main(ActivityThread.java:4507) 07-07 09:28:41.422: W/System.err(11667): at java.lang.reflect.Method.invokeNative(Native Method) 07-07 09:28:41.422: W/System.err(11667): at java.lang.reflect.Method.invoke(Method.java:511) 07-07 09:28:41.422: W/System.err(11667): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 07-07 09:28:41.422: W/System.err(11667): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 07-07 09:28:41.422: W/System.err(11667): at dalvik.system.NativeStart.main(Native Method)</p> </blockquote> <p>Thanks for advanced! :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload