Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
90
rated 0 times [  95] [ 5]  / answers: 1 / hits: 25195  / 13 Years ago, wed, june 8, 2011, 12:00:00

If you open http://app.ft.com (the Financial Times mobile web app), you are prompted to add the app to your home.



After doing this, when you open the app, you are prompted again to allow the localstoreage database size to be increased up to 50MB.




  • How can this be done? Is there some JavaScript API call? Permissions or whatever?

  • Is this iPad (iOS?) specific, or does it work on other Webkit browsers?


More From » ios

 Answers
26

I happen to know something about this ;)



There's no API for requesting an increase in storage size for an existing database. There is one way to force an increase: write data to the database in such a size that an increase is required, prompting the user. However, this would be slow and there's no way to tell the currently allocated space, so it's not recommended.



Black Frog has part of this correct: the only neat way to do this is to request a very large database when it is opened, for example:



openDatabase('databaseName', '1.0', 'My Database', 50*1024*1024, …


… to request 50MB of space.



However, when the user first visits the site, you may not want to prompt them about a 50MB limit at once; so you might think that you could ask for 5MB at first, and then later re-open it with 50MB? Unfortunately, this doesn't work - the second open attempt, with an increased quantity, succeeds silently, not prompting for a size increase and not actually increasing the available size.



The FT app therefore starts off with a 5MB preview database, so that the user isn't prompted on first load. It tries not to exceed this 5MB limit, as any space assigned has to be shared across all databases.



If the user chooses to allow storage of more content, the app then tries to open a database with a different name with 40MB of space (for which the user is prompted to approve 50MB). This allows 40MB in that database, and 5MB in the original preview database, so neither should fail when inserting rows - as 50MB total is currently the limit on iOS.



All browsers currently handle database space limits differently, so if you're planning cross-platform, test carefully. Desktop Safari handles it rather nicely, allowing much larger; Chrome doesn't allow any increase at all; etc. Expect all HTML5 implementations to differ in strange ways :)


[#91816] Monday, June 6, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sidneyh

Total Points: 118
Total Questions: 108
Total Answers: 105

Location: Mali
Member since Fri, Jun 18, 2021
3 Years ago
sidneyh questions
Tue, Jun 7, 22, 00:00, 2 Years ago
Wed, Apr 13, 22, 00:00, 2 Years ago
Wed, Aug 12, 20, 00:00, 4 Years ago
Wed, Jun 3, 20, 00:00, 4 Years ago
Fri, Apr 24, 20, 00:00, 4 Years ago
;