2

I developed an App for Android and iOS using Phonegap. Both Apps are already running successfully and available on the stores. Now I added some changes for an Update. If I have data stored (using the SQLite database) in the previous version and updating to the new one, the Storage Api on IOs 5.1 is not working anymore.

If I call

 var db = window.openDatabase("mydb", "1.0", "", 5000000);

nothing happens.

It's working fine for Android, it's also working if I do a new install or if I do not have data already stored in the database from the previous version of my app. I'm using other Phonegap functions like Notification or localStorage, which are working perfectly fine.

Any help would be much appreciated, since I'm really running out of ideas :)

Anna0815
  • 21
  • 3

3 Answers3

2

There is a fix for both issues with Webkit storage and iOS 5.1

  1. Storage moved from /Webkit to /Cache
  2. Storage is not adjusted to updated folder structure on an App update under iOS 5.1 (WebKit Bug)

https://issues.apache.org/jira/browse/CB-330

This solution seems to be more safe than just changing the location of Webkit data calling a private API. While the App is running the Webkit storage locations are used. On resuming or terminating all data is backuped to the documents folder. Timestamps ensure that ab old backup cannot overwrite newer storage data (if the app crashes...).

The best: Users that are on an older iOS Version using an App with that fix in it, will not suffer damage lost in case of any iOS updates. Thats why one should not wait...

Rene Berlin
  • 1,171
  • 7
  • 21
1

It's strange, it should be working... By the way, in iOS5.1, WebSQL is considered tempory data that can be deleted at any time...

It's possible to change the location of WebKit data calling a private API. You should be able to set the location to a secure folder like Documents. I did not test this solution yet, but look at this post :http://stackoverflow.com/questions/4527905/how-do-i-enable-local-storage-in-my-webkit-based-application

I think the safer way is to use SQLite (same as WebSQL) with a phonegap plugin. 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

There is also a fix implemented in the latest version of Cordova : https://issues.apache.org/jira/browse/CB-330 (it makes a backup of the DB files in the Document folder)

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

Samuel
  • 5,439
  • 6
  • 31
  • 43
  • Hi Samuel, thank you for your response. I'm developing in Java for Android, using Phonegap:Build to get my .ipa for the iOS. So in order to use this plugin I would have to develop using XCode on a mac, which I don't have at the moment. I still try to find a solution which works using only javascript, but if I don't find one in the next few days I will try out the plugin. – Anna0815 Mar 14 '12 at 14:15
  • How does this belongs together? Java and Phonegap:Build? – Rene Berlin Apr 11 '12 at 07:57
  • @Anna0815 : we are talking about iOS here. I think there is also a phonegap/cordova SQLite plugin for Android, but it's not very useful, because I think Android don't have this problem. And for Phonegap:build, there is a fix implemented in Cordova 1.6 : https://issues.apache.org/jira/browse/CB-330 – Samuel Apr 18 '12 at 17:03
0

There has been a Jira issue created on this: localStorage / SQLDatabase Error after App update

Anna0815
  • 21
  • 3