Skip to content

Database Format for the open() Method

Ophir LOJKINE edited this page Jun 12, 2014 · 3 revisions

Introduction

To open an existing database you must supply the new SQL.Database() method with an array of integers where each integer represents a byte of the database file.

Conversion from binary string to byte array

If you have a binary string representing your database, you can convert it to an array of bytes:

    function bin2Array(bin) {
        'use strict';
        var i, size = bin.length, ary = [];
        for (i = 0; i < size; i++) {
            ary.push(bin.charCodeAt(i) & 0xFF);
        }
        return ary;
    }