SQLite database on PhoneGap / iOS - More than 5mb possible
Asked Answered
C

3

7

I'm a little confused about the limitations of using SQLite in a Phonegap-Native-App on iOS.

You can read many posts about the limit of 5mb storage and the fact, that your Ipad can ask you to increase the storage.

Now I've managed to insert nearly 7000 rows into my SQLite database, using the usual Phonegap-Storage-API. The corresponding db-file has a size of 26 MB. A following select-statement "select * from " worked and was showing the db's content. I've done that in the simulator and on the device. I didn't get the question to increase the storage.

How can that be? Do I misunderstand something? Is there really a 5mb limit for SQLite dbs in Phonegap? I'm using Phonegap 1.2 and iOS 5.

Carsick answered 24/1, 2012 at 13:1 Comment(0)
P
10

You can use a native SQLite DB (same as WebSQL) with a phonegap plugin, and you will not have any limitation. In iOS5.1, WebSQL is considered temporary data that can be deleted at any time...That plugin save the database in the Document folder, that mean that the DB is not deleted and is saved by iCloud.

Here is the Native SQLite phonegap plugin : https://github.com/davibe/Phonegap-SQLitePlugin Regarding this plugin, there are some differences between the WebSQL API, here is an adaptor: https://gist.github.com/2009518

You should also migrate the old WebSQL db file (stored in Library/WebKit or Caches directory) to the Document folder. Here is a code to do that : https://gist.github.com/2009491

And if the data are important, you should save it to a server. I wrote a small lib to synchronize the SQlite DB to a server : https://github.com/orbitaloop/WebSqlSync

Pleuropneumonia answered 13/3, 2012 at 19:1 Comment(0)
C
3

I found out by myself:

It succeeds to open the first transaction and insert the 7000 records at one time in that one and only transaction.

If I split the inserts into separate transactions, let's say 500 records per transaction, the limitation of 5 MB takes affect. PhoneGap doesn't say anything, it just doesn't insert the records.

Carsick answered 25/1, 2012 at 9:53 Comment(2)
Did you do any more discovery on this issue?Lowering
I also did some exploratory digging into this. I managed to cram 20 datastore with 4,5MB each, totalling 90MB into a safari web app without being asked for more storage. That was in one transaction. The next transaction WILL fail.Magdalenamagdalene
F
1

The problem with HTML5 Storage on devices, it will not allow you to increase the size. Have a look with this solution:

Solved iOS Database Size Limitation of 5MB (using Plugin)

Hope this will help you.

Cheers

Furfuraceous answered 6/2, 2013 at 4:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.