how to store Image as blob in Sqlite & how to retrieve it?

后端 未结 6 1076
野的像风
野的像风 2020-11-22 04:31

I want to store an image(from url) into a sqlite database.

For that I use:

db = new DataBase(getApplicationContext());
URL url = new URL(\"http://sr         


        
6条回答
  •  半阙折子戏
    2020-11-22 05:04

    you may also want to encode and decode to/from base64

        function uncompress(str:String):ByteArray {
                import mx.utils.Base64Decoder;
                var dec:Base64Decoder = new Base64Decoder();
                dec.decode(str);
                var newByteArr:ByteArray=dec.toByteArray();        
                return newByteArr;
            }
    
    
        // Compress a ByteArray into a Base64 String.
        function compress(bytes:ByteArray):String { 
            import mx.utils.Base64Decoder; //Transform String in a ByteArray.
            import mx.utils.Base64Encoder; //Transform ByteArray in a readable string.
            var enc:Base64Encoder = new Base64Encoder();    
            enc.encodeBytes(bytes);
            return enc.drain().split("\n").join("");
        }
    

提交回复
热议问题