我想用一個插入或更換查詢,這裏即時給予我有參數與sqlite.execSQL函數傳遞的Android
String sql="insert or replace into Stock_Table values (?,?,?,?,?,?)";
sqlite.execSQL(sql, new String[]{id,name,code,vat,itmquan,pric});
現在我想另外一個插入更多的外地到此表的代碼,但字段不是字符串 它的一個字節數組格式,我想添加一個圖像到這個表中,我給這個圖像的數據類型爲表中的BLOB,但我無法將字節數組格式作爲參數傳遞到上面的sqlite .execsql func,這裏即時給我的格式,我想插入
byte []byteImage;
String sql="insert or replace into Stock_Table values (?,?,?,?,?,?,?)";
sqlite.execSQL(sql, new String[]{id,name,code,vat,itmquan,pric,byteImage});
我怎樣才能使人們有可能,我能不能夠轉換這個字節數組轉換爲字符串,我想插入圖片爲BLOB格式而已,請大家幫我找到任何解決方案
參考此鏈接http://www.coderanch.com/t/550604/Android/Mobile/insert-retreive-image-database –
this li nk非常糟糕......你不應該使用execSQL進行SELECT/INSERT/UPDATE/DELETE !!! http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#replace(java.lang.String,%20java.lang.String,%20android.content.ContentValues) – Selvin
我已經嘗試過@ sunil說,但我不能插入有錯誤,有沒有其他方法? –