Hi currently i'm using LocalStorage in my Sencha Touch + Phonegap in my application and loaded with more than 4000+ records get from WCF Rest . During development mode i have no problem running it in Google Chrome but when i packaged it and installed in iOS8 device my application crashes.
Below is the total localStorage lenght in console:
>JSON.stringify(localStorage).length
> 2917665
Model:
Ext.define("QualityAudit.model.DefectMatrix", {
extend: "Ext.data.Model",
config: {
identifier: { type: 'uuid', isUnique: true },
fields: [
{ name: "DefectMatrixID", type: "integer" },
{ name: "CustomerID", type: "integer" },
{ name: "CustomerName", type: "string" },
{ name: "DefectType", type: "integer" },
{ name: "DefectTypeName", type: "string" },
{ name: "Reference", type: "string" },
{ name: "Section", type: "string" },
{ name: "DefectDescription", type: "string" },
{ name: "SeverityID", type: "integer" },
{ name: "SeverityName", type: "string" },
{ name: "IsActive", type: "bool" },
{ name: "CreatedBy", type: "string" },
{ name: "CreatedDate", type: 'date', dateFormat: 'MS' }
]
}
});
Store:
defectSync: function (counter, totRecords, callback) {
var me = this;
if (counter == undefined)
counter = 0;
//load defect matrix local local storage
var defectsLocalStore = Ext.getStore('DefectMatrix');
defectsLocalStore.load();
var defectssurl = window.REST_DMGetListAllPaging + counter;
QualityAudit.util.Proxy.doAjaxCall(defectssurl, '',
function (response) {
var data = Ext.JSON.decode(response.responseText); //encode Json List
defectsLocalStore.load({
callback: function (records, operation, success) {
Ext.Array.each(data, function (record) {
counter++;
record.dirty = true;
defectsLocalStore.add(record);
defectsLocalStore.sync();
});
console.log('DECFECT DATA AFTER SYNC: ' + defectsLocalStore.getData().length);
//Check if all records loaded on local storage is equail to total defect rows then complete
if (defectsLocalStore.getData().length >= totRecords) {
console.log('defect loading successfull');
callback();
} else {
//Trigger again until condition is met
me.defectSync(counter, totRecords, callback);
}
},
scope: this
});
},
function (response) {
defectsLocalStore.load();
callback(0);
});
}
Does anyone tried using webSQL or SQLlite in your projects? I cant find any good sample on this.
Any help and suggestions is really appreciated.
I use SQLite in nearly every of my project. IMHO the best plugin is Cordova/PhoneGap SQLitePlugin.
You find some examples on the page, how to use the plugin and how to use SQLite in cordova.