javascript PhoneGap 上的 LocalStorage 限制

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8444556/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 03:28:30  来源:igfitidea点击:

LocalStorage limit on PhoneGap

javascriptiphonehtmlcordovalocal-storage

提问by Paymon

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

浏览器(包括 iPhone 的 Safari)上的 localStorage 通常有 5MB 的限制。

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.

由于PhoneGap具有访问更高的安全权限,包括访问设备上的其他存储机制,理论上它们应该可以消除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.

例如,它应该能够通过将数据存储在文件等上来绕过通常的限制,同时保持 API 与 localStorage javascript 对象兼容。

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

这样做了吗?还是 PhoneGap 限制在相同的 5MB?

回答by simap

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).

PhoneGap 不会做任何不同寻常的事情来扩展默认限制。在 Android 上,我在 localStorage 中得到了 250 万个字符(JavaScript 中的字符串是 UTF-16)。

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

您可以在此处找到大多数浏览器的默认限制: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.

这有助于理解限制,我使用代码创建了一个简化的测试 PhoneGap 应用程序。

回答by Mattias Wadman

PhoneGap has File APIthat 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".

PhoneGap 具有不受浏览器本地存储限制影响的文件 API,但不知道是否存在任何抽象使其表现为 HTML5 本地存储“后端”。

回答by Astronaut

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.

如果你想存储大量数据,你不应该在 localStorage 中这样做,有数据库和文件可以满足这种需求。localStorage 是一个键值数据存储,它的使用是有限的,它不应该被“破解”以满足所有需求。

回答by Aditya Murthy

Localstorage is something which is provided by the browser.

Localstorage 是浏览器提供的东西。

Localstorage is not something which is available on a device, either a mobile phone or a desktop, that is leveraged by a browser.

Localstorage 不是在浏览器利用的设备(移动电话或台式机)上可用的东西。

Since it is something which the browser provides there is no way, we can change/increase it using Phonegap since your Phonegap app runs inside the browser.

由于它是浏览器无法提供的,因此我们可以使用 Phonegap 更改/增加它,因为您的 Phonegap 应用程序在浏览器中运行。

If you want more storage space, you can use a technique which Phonegap can access like a file storage or SQlLite.

如果你想要更多的存储空间,你可以使用 Phonegap 可以访问的技术,如文件存储或 SQLLite。