-1

我在 Android 应用程序中工作。我想将以JPG/PNG格式存储的图像转换为 SQL(SQL Server 2008/10)的BLOB数据类型。你能给我Java/Android代码吗?任何类型的帮助将不胜感激。提前致谢。

4

1 回答 1

0

如图所示,首先将图像转换为数组字节,并将字节保存为blobsqlite

URL url = new URL(UrlToDownlaodImageFrom);
        URLConnection conn = url.openConnection();
        InputStream inStr = conn.getInputStream();
        BufferedInputStream buffInStr = new BufferedInputStream(inStr);
        // Need to check the size of Byte Array Buffer.
        ByteArrayBuffer baf = new ByteArrayBuffer(500);
        int current = 0;
        while ((current = buffInStr.read()) != -1) {
            baf.append((byte) current);
        }
        byte[] array = baf.toByteArray();
        return array;
于 2013-03-09T09:45:29.237 回答