Doubts about the limits of the storage API.

1,712 views
Skip to first unread message

Andre Garzia

unread,
May 31, 2012, 9:53:56 AM5/31/12
to phon...@googlegroups.com
Hello Folks,

I've been seeing some mixed up information on the web and decided to ask here about the size limits of the various database apis available to phonegap/cordova.

I understand that if I use HTML5 localStorage or WebSQL I will face a probable 5mb limit on the size of my database. Does that limit applies to the storage API shown here:

http://docs.phonegap.com/en/1.7.0/cordova_storage_storage.md.html#Storage

If it does, then is there a way to have to increase this limit or can someone point to a plugin for iOS and one for Android to have larger databases. I am building a specialized app for a vertical market for local offline record keeping, they will probably have more than 5mb.

Thanks in advance for any information
Andre


seasp...@gmail.com

unread,
May 31, 2012, 11:52:23 AM5/31/12
to phon...@googlegroups.com
My understanding is that Cordova storage is a wrapper around HTML5 storages. To get around this, we use the SQLite plugin:

https://github.com/chbrody/Cordova-SQLitePlugin

However, even with this plugin, I have seen SECURITY_ERR DOM Exception thrown when requesting more than 5MB of storage -- but only on iOS 4. If you're targeting iOS 5+ you should be okay.


Andre


--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com



--
Learn Bird Songs, Support Conservation: http://www.larkwire.com
Bikewise: http://www.bikewise.org

Irfan Shirur

unread,
May 31, 2012, 12:57:48 PM5/31/12
to phon...@googlegroups.com
Is Cordova making ue of the HTML5 SQLite or they have created a native plugin for this ?

Because HTML5 SQLite is no longer be used in future, they are coming up with the new DB called index DB for HTML5.

Warm Regards
Mohammed Irfan 
Warm Regards
Mohammed Irfan


JonFoulkes

unread,
Jun 2, 2012, 11:29:18 AM6/2/12
to phonegap
If you are creating an Enterprise App, then you could use a platform
Like Rover Apps and leverage the secured local storage APIs, which are
plug-replacement analogs for the Cordova versions (which are there,
but subject to the limits outlined above).
Besides being secure (encrypted), they are persistent and not limited
to a given size.

So whether using Name Value Pair or SQL, it’s all done in a way that
is not size limited.
Best of all, for enterprises, your ‘app’ is server published to the
secured container app, no app store hassles.

Check it out at http://roverapps.com/phonegap/

JonFoulkes

unread,
Jun 2, 2012, 11:35:49 AM6/2/12
to phonegap
Oh, the other thing about the standard HTML storage implementation on
iOS is that not only is there a limit, there is the issue of
persistence. The OS does NOT guarantee your data is durable. The
storage is in a location the OS is free to dispose of objects if the
entire device is running low on space. So consider that as well.

filmaj

unread,
Jun 4, 2012, 3:17:08 PM6/4/12
to phonegap
Cordova provides backup shims for SQLite and localStorage. However,
how it works is if the native WebView component on the platform
provides these storage mechanisms already (for example, Android 2.2
and above, iOS 4 and above, and other similar platforms), then Cordova
will "step back" and let the native platform do its thing.

As such, in most modern cases today, the storage capabilities that
Cordova tries to fill in are not actually enabled.

If you *really* want, you can access these native shims for storage,
but you will have to use some different approaches.

On Android, during phonegap/cordova .js initialization, we test
whether the storage shim should kick in. (You can see that here:
https://github.com/apache/incubator-cordova-js/blob/master/lib/android/platform.js#L54-L93).
This shim eventually routes to this JavaScript interface:
https://github.com/apache/incubator-cordova-js/blob/master/lib/android/plugin/android/storage.js
. From your app, if you want to use this, you could do something like:

var storage = cordova.require('cordova/plugin/android/storage');
var storageAPI = storage.CupcakeLocalStorage;

Then on the "storageAPI" object you will have methods such as setItem,
removeItem, getItem and clear. These methods will route to native
methods that use Java's SQLite under the hood.

Andre Garzia

unread,
Jun 9, 2012, 5:33:12 PM6/9/12
to phon...@googlegroups.com
Thanks very much for the answer. I just want to clarify one point:

If I use a plugin such as https://github.com/chbrody/Cordova-SQLitePlugin/ I will still face the 5mb limitation?

Thanks

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com



--
http://www.andregarzia.com -- All We Do Is Code.
http://fon.nu -- minimalist url shortening service.

seasp...@gmail.com

unread,
Jun 10, 2012, 4:35:06 PM6/10/12
to phon...@googlegroups.com
In general, no, but I have seen a SECURITY_ERR thrown on iOS4 devices when requesting >5MB through cordova-sqlite.
Reply all
Reply to author
Forward
0 new messages