4

This is basically the same question as this one, except that I'm not using PhoneGap (so I don't think any of the solutions offered there are applicable).

I have a pure HTML/JS webapp that works offline (using WebSQL for storage, and AppCache for disconnected use).

The app has an 'export' option which serializes the data as JSON and uploads it to an AWS S3 bucket for backup; and a corresponding 'import' option for restoring. However as this is a full dump/restore of the entire db, the process is not all that fast so typically I backup on a weekly basis.

As anticipated, the OTA upgrade from iOS 5 to 5.1 deleted my local webSQL database, but I was able to successfully restore the data from S3 (luckily, I'd just done a backup prior to the upgrade).

Unfortunately, after a couple of weeks running iOS 5.1, it has again decided that it needed the space, and deleted my webSQL db. Again, I'm lucky that this has occurred just after my regular weekly backup; but I'm concerned that if this becomes a regular occurrence (iOS deleting this 'temporary' database to reclaim space) it won't be long before I'm caught out by not having backed up for a few days.

I am planning to eventually move off the now defunct WebSQL, and use IndexedDB; but of course iOS doesn't yet support IndexedDB. I'm also planning to modify the export/import process in my app such that instead of doing a full dump/restore, it just syncs any changed records with S3 (so that backing up to S3 is less of hassle, and therefore likely to be done more frequently than weekly).

In the meantime, are there any hacks/workarounds/tricks to ensuring that a WebSQL db is not cleared by iOS 5.1; or is there any way that I can predict when a cleanup is likely to happen, so that I can attempt to preempt it by running an export to backup my data?

Community
  • 1
  • 1
Scott
  • 1,518
  • 1
  • 15
  • 23

1 Answers1

0

The solutions offered by the PhoneGap community are definitely applicable. For us, the code at https://issues.apache.org/jira/browse/CB-330?focusedCommentId=13237796&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13237796 worked the best for us, as long as it was called before initialising any WebView (ie, in your app's init() method) as well as calling it after initialising the WebView.

The above linked code moves the database to a safe location as well as editing the WebKit preferences to reference the new location. It needs to be run twice so as to move and update existing databases before loading WebKit and updating to the new location after WebKit is loaded (as WebKit will create the preferences pointing to the wrong/unsafe location)

EionRobb
  • 532
  • 5
  • 13
  • 1
    I think you may have missed the bit where I said that I'm working with a pure HTML/JS app; ie. a website, viewed in Safari..and then added to the Home Screen (via the "Add to Home Screen" button) so that it becomes a full screen "app". So in my case, there is no app init() method or WebView. – Scott Apr 13 '12 at 05:34
  • Ah, sorry about that. Wasn't clear from the question. Maybe you should mention that it's a webapp and not an app. – EionRobb Apr 17 '12 at 02:38
  • Good point...thanks EionRobb. I've updated it to say "webapp" instead of "app" – Scott Apr 17 '12 at 06:59