有沒有辦法將文本追加到我的sqlite數據庫中已有的文本上,而無需再次手動鍵入舊的代碼?將文本追加到已存在的sqlite條目
我像它會是這樣的:
UPDATE myTable set myText = myText || 'new text'
但是,當我嘗試在Android的它返回一個 「空bindArgs」 錯誤
方法:
public void appendConvo(String name, String convo) {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("update friends set convo = convo || '" + convo + "' where name = '" + name + "'" , null);
db.close();
}
錯誤:
FATAL EXCEPTION: main
Process: com.acbk.acbk, PID: 13438
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.view.View$DeclaredOnClickListener.onClick(View.java:4745)
at android.view.View.performClick(View.java:5702)
at android.view.View$PerformClick.run(View.java:22546)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.view.View$DeclaredOnClickListener.onClick(View.java:4740)
at android.view.View.performClick(View.java:5702)
at android.view.View$PerformClick.run(View.java:22546)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.IllegalArgumentException: Empty bindArgs
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1791)
at com.acbk.acbk.DataBaser.appendConvo(DataBaser.java:81)
at com.acbk.acbk.Chat.send(Chat.java:137)
at java.lang.reflect.Method.invoke(Native Method)
at android.view.View$DeclaredOnClickListener.onClick(View.java:4740)
at android.view.View.performClick(View.java:5702)
at android.view.View$PerformClick.run(View.java:22546)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)