Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LocalStorage limit on PhoneGap

There is usually a limit of 5MB on localStorage on browsers, including iPhone's Safari.

Since PhoneGap has the access higher security privileges including access to other storage mechanisms on the device, in theory they should be able to eliminate the limit of 5MB.

For example, it should be able to get around the usual restrictions by storing the data on a file, etc while keeping the API compatible with localStorage javascript object.

Is this done? Or is PhoneGap limited to the same 5MB?

like image 441
Paymon Avatar asked Dec 09 '11 11:12

Paymon


People also ask

Is there a limit to local storage?

LocalStorage should be avoided because it is synchronous and will block the main thread. It is limited to about 5MB and can contain only strings. LocalStorage is not accessible from web workers or service workers.

What is the maximum size of session storage?

SessionStorage is used for storing data on the client side. Maximum limit of data saving in SessionStorage is about 5 MB.


3 Answers

PhoneGap doesn't do anything out of the ordinary to extend the default limits. On Android, I get 2.5M characters in localStorage (Strings in JavaScript are UTF-16).

You can find default limits for most browsers here: http://dev-test.nemikor.com/web-storage/support-test/

This was helpful in understanding the limitations, and I used the code to create a simplified test PhoneGap app.

like image 200
simap Avatar answered Oct 06 '22 10:10

simap


PhoneGap has File API that should not be affected by browser local storage limits but don't know if there exist any abstraction to make it behave as HTML5 local storage "backend".

like image 22
Mattias Wadman Avatar answered Oct 06 '22 09:10

Mattias Wadman


If you want to store a large amount of data you should not do that in localStorage, there are databases and files for that kind of need. localStorage is a key-value datastore, it's use is limited and it should not be "hacked" to fit all needs.

like image 30
Astronaut Avatar answered Oct 06 '22 08:10

Astronaut