Search code examples
javascriptcordovasencha-touch-2persistencelocal-storage

Offline persisting storage in Sencha mobile app


I am new to mobile app development. I am creating cross-platform app using Sencha + Phonegap. My goal is to store user-written text in mobile (offline storage) and some other text data related to it, that would persist even if mobile restarts, which would be then uploaded to server, once mobile has connection.

According to this http://docs.sencha.com/touch/2.3.2/#!/api/Ext.data.proxy.Proxy Sencha provides 2 client side storages.

LocalStorageProxy - saves its data to localStorage if the browser supports it
MemoryProxy - holds data in memory only, any data is lost when the page is refreshed

MemoryProxy is out of question. And LocalStorage uses HTML5 storage and I dont believe that that lasts after reboot.

So what I need is some kind of database, which will be accessible from Sencha, on both Android and IOS, in offline mode. Is there such a thing?


Solution

  • Your assumption is wrong, localStorage is persistent between applications restarts and application reboots. Are you maybe confusing it with sessionStorage? As far as I know, data will be wiped out only if the user actively clears application data (for example on Android from the application menu).

    Anyway, since you are using Cordova/Phonegap, you have these Storage options:

    • localStorage, key/value persistent storage (support table)
    • WebSQL, offers more full-featured database tables accessed via SQL queries (Android, BlackBerry 10, iOS, Tizen).
    • IndexedDB, more features than LocalStorage but fewer than WebSQL (only Windows Phone and Blackberry).

    Plus you could use: