我只是想知道,我该如何将字节数组转换为blob?如何将字节数组转换为Android中的Blob数据类型
我的数据库看起来是这样的:
Photo
id (int) | image_key (blob)
这是我的代码:
//this for getting data from picture
Bitmap yourImage = extras.getParcelable("data");
// convert bitmap to byte
ByteArrayOutputStream stream = new ByteArrayOutputStream();
yourImage.compress(Bitmap.CompressFormat.PNG, 100, stream);
//the problem is right here, i want to convert this byte array, to a blob data type
byte imageInByte[] = stream.toByteArray();
我如何转换这个字节数组到我的数据库的照片,并把它放在现场image_key(BLOB) ?因为我尝试过但有错误。有人能帮我解决这个错误吗?请我需要帮助..
我错误?看起来像这可能是重复的副本:http://stackoverflow.com/questions/4191136/how-to-store-and-retrieve-a-byte-array-image-data-to-and-from-a -sqlite-databas – IrishGeek82
@ IrishGeek82好吧,错误看起来像我不能把imageInByte [B @ 421a0a0的值放到blob数据类型中,所以查询是INSERT INTO Photo(image_key)VALUES('[B @ 421a0a0' ),请纠正我,如果我错了。 – user3747208
您是否在使用类似的东西? cv.put(CHUNK,buffer); // table CHUNK blob type字段 long rawId = database.insert(TABLE,null,cv); // TABLE table name – IrishGeek82