title: Flex AIR and SQLite blobs: Why 3-5 extra bytes added when storing blobs?
body: <p>I'm using Flex 4 Air (sdk 4.5) and SQLite to store blobs (png files) using this code:</p>
  
  <pre><code>sql = "INSERT INTO pages (id, data) VALUES (:id, :data)";           
  sqlStatement.text = sql;        
  sqlStatement.parameters[":id"] = file.name;         
  sqlStatement.parameters[":data"] = file.data;
  sqlStatement.execute(); 
  </code></pre>
  
  <p>The table is defined like this:</p>
  
  <pre><code>CREATE TABLE "pages" ("id" varchar, "data" blob)
  </code></pre>
  
  <p>The problem is that the data stored has 3-5 extra bytes added to it, in the beginning of the data chunk. (If I store a 1000 bytes png, the data stored in the blob typically become 1004 bytes - confirmed by examining the SQLite file outside the Flex environment).</p>
  
  <p>When reading the data back, using...</p>
  
  <pre><code>sql = "SELECT id, CAST(data AS ByteArray) AS data FROM pages"
  </code></pre>
  
  <p>...I have to trim the data ByteArray 3-5 bytes to get a valid image.</p>
  
  <p>Clue?</p>