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

13,693

Solution 1

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

Solution 2

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.

Solution 3

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

Share:
13,693
Sascha
Author by

Sascha

Updated on August 07, 2022

Comments

  • Sascha
    Sascha over 1 year

    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.

  • James Andino
    James Andino about 12 years
    Did you do any more discovery on this issue?
  • oligofren
    oligofren over 10 years
    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.