lundi 16 février 2015

SQLite blob data type retrieve result not same native android and phonegap

I developed 2 application for android. 1 of the application developed with phonegap another 1 is Android native. Both of the application have need to insert image. I used SQLite blob data type for image insert. Android Native application is not problem for me. Phonegap application retrieve result not same native . I thought error exists blob object create process or blob object insert to SQLite process.

using phonegap-1.4.1.js.


Base64 String convert to Blob object javascript function (Phonegap Application)



function b64toBlob(b64Data){

contentType = 'image/png';
sliceSize = 512;


var BASE64_MARKER= ';base64,';
var base64Index = b64Data.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = b64Data.substring(base64Index);

var byteCharacters = b64Data;
var byteArrays = [];

for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
var slice = byteCharacters.slice(offset, offset + sliceSize);

var byteNumbers = new Array(slice.length);
for (var i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}

var byteArray = new Uint8Array(byteNumbers);

byteArrays.push(byteArray);

}

var BlobBuilder = window.BlobBuilder ||
window.WebKitBlobBuilder ||
window.MozBlobBuilder ||
window.MSBlobBuilder;
var bb = new BlobBuilder();

bb.append(byteArrays.buffer);

var blob = bb.getBlob(contentType);

var db = window.sqlitePlugin.openDatabase(Mydb , ver, "", size);

db.transaction(function(tx) {tx.executeSql("Insert Into "+ DOPhotoTable +"( RefTranNo,Photo) values(?,?);",["C007", blob]);});
}


SQLite Debugger Application show the blob data (Phonegap Application)


SQLite Debugger Application View


SQLite Debugger Application show the blob data (Native Application)


SQLite Debugger Application View


Aucun commentaire:

Enregistrer un commentaire