我将我的图像文件转换为字节并使用下面给出的内容值插入数据库。我需要将图像作为字节存储到博客数据库字段中
String fileName="/sdcard/"+pkDelivery+".png";
Bitmap bMap = BitmapFactory.decodeFile(fileName);
imgSignature.setImageBitmap(bMap);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bMap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
String aa =byteArray.toString();
ContentValues initialDelay15 = new ContentValues();
dbAdapter = new DatabaseAdapter(this);
dbAdapter.open();
initialDelay15.put("Signature",
byteArray);
dbAdapter.UpdateRecord("tblDelivery", initialDelay15, "PKDelivery"
+ "=" + pkDelivery, null);
当尝试将图像转换为字节时,字节数组显示如下所示的值,如下所示
[-119, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 1, -62, 0, 0, 0, -106, 8, 6, 0, 0, 0, 77, 112, -120, 16, 0, 0, 0, 4, 115, 66, 73, 84, 8, 8, 8, 8, 124, 8, 100, -120, 0, 0, 9, 80, 73, 68, 65, 84, 120, -100, -19, -35, 65, 110, -36, -42, 25, 7, -16, 127, 111, 48, 55, 96, 111, -96, -34, -128, 58, 65, -108, 19, 72, 39, -88, 125, 1, 39, -18, 1, 26, 36, -21, 2, -75, 54, 93, 38, -50, 5, -36, 40, -35, 117, 17, -53, 6, -70, 43, 80, -51, -70, 27, -23, 0, 69, -31, 46, 40, 86, -14, 68, 51, 26, 114, 56, -113, 28, -50, -17, 7, 60, 100, 19, 81, 67, 37, -28, 127, -8, -8, -66, -17, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 113, -106, -28, -37, 36, 31, -110, 124, 74, 114, -101, -28, 42, -55, -7, -104, 31, 10, 0, -10, 105, -111, -28, -21, 36, 55, 105, -62, 111, -35, 120, 127, -1, -17, 2, -64, 44, 84, 73, -34, -92, 121, -22, -37, 20, -128, -85, 97, 8, 0, 7, -83, 78, 19, -128, -37, -122, -33, -22, 48, 77, 10, -64, 65, -86, -109, -4, -108, -2, 1, -40, -114, 119, -91, 63, 56, 0, -20, -30, 60, -49, -65, -1, -21, 58, 0, 96, -46, 22, 73, 94, 100, -8, 0, 20, -124, 0, 76, 90, -69, 2, -76, -53, 2, 24, 83, -93, 0, 28, -68, 62, 43, 64, 45, -106, 1, -32, -32, -75, 1, -72, -17, -16, 107, -57, 117, -103, -45, 2, -128, -51, -22, 36, 111, 83, 46, 0, -37, 16, 84, 80, 15, -64, -88, -22, 12, 83, 2, -47, 101, 124, 76, -14, -78, -60, -55, 1, -64, 58, -25, 121, -24, -1, 89, 98, 92, 37, -7, 50, -98, 0, 1, 24, -39, 62, 106, 0, 55, -115, -53, 52, -17, 29, 1, 96, 52, -37, 54, -63, 30, 106, -36, 37, -7, 46, 2, 16, -128, -111, -107, -88, 1, 92, 13, -64, -41, 49, -3, 9, -64, -56, -86, -108, -85, 1, -4, -108, 100, -103, -28, 34, 2, 16, -128, -111, -75, 1, 88, -22, -3, 95, 27, -128, 0, 48, -86, 58, 101, 3, -16, 42, -51, 10, 80, 0, 24, 85, -99, -78, 53, -128, 87, -9, -65, 19, 0, 70, 117, -106, -78, 1, 120, -103, -28, -92, -56, -103, 1, -64, 6, 106, 0, 1, 56, 74, 37, 3, 80, 13, 32, 0, -109, -96, 6, 16, -128, -93, 84, 58, 0, -105, 17, -128, 0, 76, 64, -107, 113, -118, -32, 1, 96, 84, 109, 0, -106, 8, 63, 1, 8, -64, 100, -44, 41, 95, 4, 95, 23, 57, 51, 0, -40, -96, -114, 34, 120, 0, -114, 80, -23, 0, -68, -116, 34, 120, 0, 38, 64, 17, 60, 0, 71, -87, 116, 17, -68, 0, 4, 96, 116, -117, 36, 47, 82, 54, 0, 95, 71, 13, 32, 0, 35, -45, 5, 6, -128, -93, 52, 70, 23, -104, -117, 34, 103, 6, 0, 27, 84, 81, 4, 15, -64, 17, 42, 29, -128, 87, 17, -128, 0, 76, 64, -99, -28, 109, -54, 6, 96, 93, -28, -52, -32, -120, -100, -92, 121, -71, -2, 54, -51, 69, -42, -114, 55, 81, 116, 11, -21, -44, -47, 5, 6, 14, -34, 73, -74, -69, -112, 127, -118, 26, 36, 104, -107, 14, -64, -53, -72, -2, 96, 47, -66, 78, -73, -117, -15, 54, -66, -115, 114, -36, 116, -127, -127, -103, 88, -92, -1, -73, -39, -37, -104, 42, -27, -8, -108, -18, 2, -13, 93, 4, 32, -20, -43, -5, -20, 118, -95, -34, 70, -95, 46, -13, -89, 11, 12, -52, -44, -97, 51, -52, 69, -5, 85, -23, 15, 14, -123, -24, 2, 3, 51, 54, 84, 8, 122, 42, 100, -114, 116, -127, -127, -103, -5, 38, -61, 95, -56, -65, 47, 122, 6, -80, 31, 85, 116, -127, -127, -39, -85, -77, -97, 11, -6, -105, -110, 39, 1, 3, 43, 29, -128, 87, 17, -128, 48, -118, 69, -10, 59, -43, -13, -69, 114, -89, 2, -125, -88, 83, 62, 0, -21, 34, 103, 6, 60, -23, 93, -10, 123, -111, -101, 30, -27, 80, -44, -47, 5, 6, -114, -50, 87, -39, -1, -59, -2, 125, -79, -77, -127, 126, 74, 7, -32, 101, -44, 0, -62, 36, -44, 41, 115, -47, -1, -85, -44, 9, 65, 71, -70, -64, -64, 17, 91, -92, 9, -88, 62, 23, -13, 93, -113, -97, -127, 41, -47, 5, 6, -24, 93, 42, 113, -105, -90, 125, 90, -41, 48, 60, 45, 114, 86, -80, -98, 46, 48, -64, -1, -43, -23, 127, 113, -97, -33, 31, -93, -21, 2, -101, -77, -3, -97, 22, 60, 73, 23, 24, -32, 51, -69, 76, -119, -2, -16, -24, 56, 127, -20, -8, -77, -81, -10, 123, 90, -16, 43, -70, -64, 0, 79, -22, -37, 66, -19, 38, -97, 127, -61, 125, -43, -15, -25, 5, 33, -91, 84, -47, 5, 6, 88, -29, -117, -12, -65, -40, -21, -107, 99, -99, 117, -4, 121, 37, 20, -20, 91, -23, 0, -4, 24, 1, 8, 7, 101, -105, -18, 49, 79, -19, 34, 113, -38, -15, 24, -17, -10, 114, 86, -96, 11, 12, -80, -91, -66, -35, 99, -82, -41, 28, -17, -76, -29, 113, 4, 33, 67, -85, -93, 11, 12, -80, -91, 23, -23, 119, -31, -73, -91, 18, 79, -7, 109, -57, 99, 105, -66, -51, 80, 74, 7, -32, 101, -42, 95, 7, -64, 1, 56, 73, -1, 27, -64, -117, 103, -114, -35, -11, 120, -80, 11, 93, 96, 96, -58, -50, -45, 76, -69, -76, 23, -32, -121, 52, 33, -76, 107, 29, -46, 34, -55, -5, -12, -69, 9, -4, 117, -117, -29, 11, 66, 74, 40, -35, 5, 70, 0, 66, 65, -49, 5, -43, 109, -102, 69, 0, 125, 47, -54, -66, -91, 18, 119, 105, -90, 62, -97, 35, 8, -39, -105, -74, 6, 80, 23, 24, -104, -71, 46, 79, 107, 111, -45, -19, 69, -3, 121, -121, 99, -81, -114, 47, -74, -4, 29, -126, -112, -95, -23, 2, 3, 71, -92, 111, 80, -35, -28, -95, -51, -39, 58, 39, -23, 127, 35, -7, -31, -119, -29, -83, 35, 8, 25, 74, -107, -28, -37, -108, -17, 2, 35, 0, 97, 68, -65, 100, -73, 11, -7, 54, -51, 55, -25, -43, 11, 121, -105, -9, -126, -85, -35, 99, -98, -45, -11, -8, 110, 58, -84, -86, -94, 11, 12, 28, -83, 33, 47, -18, 55, 121, 88, -34, -35, -9, -67, -32, -89, 116, -81, -111, -22, 26, -72, -89, 29, -113, -49, 124, -99, 68, 23, 24, 56, 122, -5, -72, -40, -1, -71, -61, -49, 126, -45, -29, 28, -70, 22, -23, -97, -10, -8, 29, -52, 75, 29, 69, -16, -64, -67, -66, -45, -105, -5, 24, -21, -70, -57, 60, 71, 16, -78, 45, 1, 8, -4, -54, 46, -85, 58, -121, 28, 119, -23, -1, -18, 78, 16, -14, 28, 69, -16, -64, 70, -41, 25, 63, 8, 119, -7, -42, 44, 8, 89, 71, 0, 2, 91, 89, 100, -36, 48, 124, 106, 87, -119, 46, 4, 33, -113, -115, 81, 3, -8, 93, 4, 32, -52, -62, 69, -102, 101, -35, 37, 67, -16, 63, -39, -83, 107, 77, 34, 8, 105, 40, -126, 7, 6, 115, -111, -49, 123, -114, -106, 26, 63, -27, -7, 34, -3, -89, 116, 13, -62, 62, -65, -125, -23, -86, -46, 124, -103, 42, 89, 4, 47, 0, -31, 72, -44, 105, -34, 121, -108, 14, -60, -101, 52, -33, -20, -85, 45, 63, -25, -85, -114, -57, 127, -43, -7, 47, -63, 20, -75, 1, 88, -22, -1, -53, 101, -44, 0, -62, -47, -86, -46, 124, 3, -66, 75, -7, 80, 124, -101, -25, -97, -32, 4, -31, 113, -87, -45, -4, 127, 33, 0, -127, -30, 22, 105, 110, 8, -1, 78, -7, 64, 108, 119, -64, 120, 106, 99, 82, 65, 120, 28, -22, -88, 1, 4, 38, 96, -105, 70, -38, 67, -115, -101, 52, -5, 36, 86, -9, -97, 73, 16, -50, 91, -23, 18, 8, 1, 8, -84, -11, 69, -58, 15, -63, -43, -15, 54, -55, 95, 58, -2, -116, 32, 60, 12, 99, -44, 0, 62, 53, -29, 0, -112, 100, 58, 29, 104, -122, 24, -126, 112, -70, 74, -105, 64, -76, 1, 88, -107, 56, 57, -32, 112, -67, -56, -8, -31, 37, 8, -25, 77, 17, 60, 48, 89, -69, 108, -89, 52, -43, -15, -3, -96, 127, 33, 118, 81, -91, 108, 9, -124, 34, 120, 96, 107, -117, 12, -77, 66, -17, 60, 15, -27, 23, -53, 1, -114, 55, -60, -8, -5, -128, 127, 39, -6, 41, -67, 15, -32, 50, -55, -53, 8, 64, 96, 75, 85, -122, -39, -98, -23, -51, 19, -57, -66, -56, 56, 93, 107, 86, -57, 77, -110, 111, 99, 113, 68, 105, 117, -54, -106, 64, 44, -93, 6, 16, -24, 104, -88, -14, -120, -89, 66, -16, -79, 42, -51, 34, -123, 49, -118, -12, 87, 71, 91, -93, 120, -42, -19, 79, 69, 7, -25, 41, 95, 3, 40, 0, -127, -50, -50, 83, 38, 4, 31, 107, -117, -12, -105, 3, -4, -34, -95, 66, -79, -19, 102, 99, 26, 109, 119, 106, 0, -127, -125, 49, -44, -54, -48, 46, 33, -72, -22, 36, -45, 121, 74, 124, 124, 99, 125, 92, -68, -49, -13, -38, 21, -96, -91, 107, 0, 5, 32, -48, -37, 80, 43, 67, 119, 9, -63, 85, 23, 73, 126, 28, -24, 115, 13, 53, 62, -92, 121, -81, -24, -122, -5, -76, 42, 106, 0, -127, 3, 51, -44, -54, -48, 79, -39, -33, -42, 70, 85, -102, -43, 126, -53, -127, 62, -25, 80, -29, -15, 20, -22, -79, -33, -120, -85, -108, 47, -127, 80, 3, 8, -20, 108, -111, 97, 86, -122, -18, 51, 4, 87, 77, 113, -22, -76, 29, -57, -8, -76, 88, 71, 13, 32, 112, -64, -122, 8, -63, -69, -116, -73, -55, -19, 69, -90, 55, 117, -38, -114, -71, 63, 45, -42, 41, 95, 2, -95, 6, 16, 24, -44, -17, 51, 76, 8, 78, -95, 6, -81, 93, 117, 58, 118, -8, 109, 26, 55, 105, -98, -100, 14, 61, 24, 75, -81, 0, 93, 70, 9, 4, -80, 39, -17, -78, -37, 13, -22, 58, -45, -69, -95, -113, 29, 118, 115, 13, -58, 69, -102, 85, -77, -91, 75, 32, -66, 44, 113, 114, -64, -15, -38, -11, 38, 53, -59, 41, -86, -79, -61, 109, -105, -47, -66, 95, 60, -53, 116, -126, -79, 74, -7, 21, -96, 87, 57, -82, 119, -84, -64, -120, -6, -34, -88, -122, 44, -113, 24, -38, 80, 11, 127, -90, 48, -38, 119, -116, -81, -45, 4, 67, -55, 47, 30, 85, -54, 46, -128, -7, 20, 37, 16, -64, 8, -6, 76, -115, -66, 28, -27, -109, 110, -81, -53, 123, -49, 63, 101, -70, 11, 109, -42, -115, 15, 105, 2, -22, 69, -10, -13, -44, 84, -89, 9, -33, 82, -25, 115, 23, 1, 8, -116, -88, -53, 38, -69, 99, -82, 12, -19, -22, 58, -49, -97, -49, -11, -93, 127, 127, -111, -26, 93, -44, 101, -90, 89, -110, -15, -36, -72, 73, 51, -99, -8, 58, 15, 1, -39, -11, -23, -79, 116, 15, 80, 37, 16, -64, 100, 108, 19, 26, 83, 89, 25, -70, -83, 69, 54, -97, -41, 117, 54, -33, -128, -65, 76, 83, -88, -67, -36, 112, -116, 67, 24, -73, 105, 2, -78, -99, 94, 109, 67, -78, -3, 111, -71, -56, 56, 43, 64, -107, 64, 0, -109, -78, 77, 104, 84, -93, 125, -70, -35, 92, 36, -7, -104, -121, 115, -7, 57, -35, -89, 118, 79, -110, -4, 97, -27, 56, 115, 25, -1, 45, -8, -69, -106, 81, 2, 1, 76, -36, -53, 124, 126, -77, -1, 24, 55, -82, 85, 85, -102, -65, -55, 101, 14, 115, 10, 117, -116, 113, 21, 37, 16, 0, -77, 53, -25, -89, -59, 93, -57, -113, 81, 2, 1, 112, 84, -38, -50, 54, -105, 57, -18, -89, -59, -53, 28, -18, 84, 58, 0, 3, 106, -97, 22, 127, -50, -8, -31, -76, -17, -47, -82, 0, 21, -128, 0, -84, 117, -102, -7, 5, -29, 50, 74, 32, 0, -24, -23, 52, -121, 27, -116, -53, 88, 72, 5, -125, -5, -51, -40, 31, 0, 70, 118, 122, 63, 78, -18, -1, 57, -43, -89, -84, -45, 36, 127, 27, -5, 67, 0, 48, 127, 85, 30, 10, -5, 127, -50, -8, 79, -127, -97, -46, -76, -28, 3, -128, -30, 74, -73, 63, 91, 55, 14, -91, -59, 30, 0, 51, 80, -91, -39, -2, -88, 100, -5, -77, 77, -29, 113, 111, 86, 0, -40, -101, 58, -27, -73, 63, -38, 38, 4, -89, -6, -50, 18, -128, -103, 56, 79, -77, -59, 82, -23, -112, -5, 71, -102, 34, -8, -10, 93, -92, 54, 123, 0, 20, 83, -91, -39, -111, -66, -28, -18, -17, -19, -72, -5...
但是当它传递给内容值时,它显示如下所示
Signature=[B@44fae130
问题是我想知道哪些数据需要存储在我的数据库中,其数据类型为博客的字段名称签名,即第一个有大量数字或其他的数据(= [B @ 44fae130 )
我使用图像作为字节存储到数据库是正确的方式..............有没有其他方法将图像保存为数据库的字节...?< / p>
答案 0 :(得分:0)
log以这种方式打印值[B @ 44fae130。