5

In a normal Android web app the maximum size for a WebSQL database is normally around 8MB. In a hybrid web app I am making I would like to increase this limit. How would I go about doing that?

It seems that WebStorage might have something to do with it, but the only method I can see there that seems to set the size, setQuotaForOrigin, is marked deprecated.

Sample code (that is not deprecated) is welcome :)

oligofren
  • 20,744
  • 16
  • 93
  • 180
  • I'm looking for the exact opposite solution. iOS7 has a "bug" that throws a security exception when you try to exceed the size limit. So I need to downsize my DB to avoid this. I'll post whatever I find on that regard. – Chepech Sep 13 '13 at 18:06

2 Answers2

5

The quota for a web app seems to differ from that of a hybrid app (as in something running within a view). Regardless, by implementing the following in your android.app.Activity subclass you will double the quota until it finally stops at approximately 48MB.

@Override
public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize, long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
    quotaUpdater.updateQuota(estimatedSize * 2);
}

The user will not be asked to interact when this happens.

oligofren
  • 20,744
  • 16
  • 93
  • 180
1

You may want to look at this other question on how to increase quota limit.

Looks like changing the size is only a problem for users that already have a local DB created, this is because there is no way to change the size of the DB when running upgrade scripts for versioning. That said, you just only need to change the size in the initialization script (code in JavaScript):

var size = 10 * 1024 * 1024; // changed from 5 to 10MB
var db = openDatabase("oversized_db", "v1.1", "Ten MB DB", size);

Take into account that this will only affect new users. All users that have previously created a DB with a different size need to clear their cache (you have controll of the cache on a webView so its not that bad) but all previous data would be lost (unless you manually migrate it to the new DB with native code). In my case I have to do the same but decreasing the size. That would take care of the issue.

Hope this helps.

Community
  • 1
  • 1
Chepech
  • 5,258
  • 4
  • 47
  • 70
  • this is something else. this won't affect the quota set by the Android OS. this only sets the size of the existing database. and I have yet to see that actually do _anything_. in all tests I have done that size is just baloney. I can set a size of 10 byte and I can still fill it up to the quota is exceeded. I will add an answer now with more info. – oligofren Sep 16 '13 at 21:14
  • This is how its done for a regular web app. I'm not sure how you are doing it. But limits are usualy set by the browser, this is the way to attempt to create a DB of a set size. – Chepech Sep 17 '13 at 23:12
  • I know that is the way it is done for a regular web app. I am just saying that the size argument does _nothing_. I should do the expected thing - set the size, but it seems to be ignored by most browsers. the real max size is set by the browser/view. – oligofren Sep 24 '13 at 12:33
  • 1
    That is precisely how it works. You can start with a DB size of 0 and let it "grow" to the space it requires. Size is only used in some OS/Browsers to verify for remaining quota, it is even called "suggested size" in some of iOS Safari documentation. So, as you say it doesn't set a size. – Chepech Oct 01 '13 at 12:21