【发布时间】:2018-07-23 11:08:20
【问题描述】:
朋友们,我想更新列 'IS NULL' 的 Blob 数据字段 每当我尝试以下代码时,它都会产生错误 我只想知道如何更新 Blob 数据类型?
Bitmap icon = BitmapFactory.decodeResource(getResources(),R.drawable.audiobook);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.PNG,100,stream);
simple = stream.toByteArray();
String sql = "UPDATE Settings SET image = "+simple+"where image IS NULL";
db.execSQL(sql);
当我尝试这段代码时,它会产生这个错误
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.blackhat.rhythmbox/com.blackhat.rhythmbox.Welcome}: android.database.sqlite.SQLiteException: unrecognized token: ":" (code 1): , while compiling: UPDATE Settings SET image = :[B@27a97db7
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2521)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.database.sqlite.SQLiteException: unrecognized token: ":" (code 1): , while compiling: UPDATE Settings SET image = :[B@27a97db7
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:898)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:509)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1704)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1635)
at com.blackhat.rhythmbox.Welcome.addtoDatabase(Welcome.java:124)
at com.blackhat.rhythmbox.Welcome.code(Welcome.java:67)
at com.blackhat.rhythmbox.Welcome.onCreate(Welcome.java:57)
at android.app.Activity.performCreate(Activity.java:6100)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
我在哪里做错或我做错了什么???
【问题讨论】:
标签: android arrays database sqlite blob