简体   繁体   中英

PhoneGap based App does not work after After App update in iOS5.1

I have a PhoneGap based iOS app which uses SQLite DB for offline storage. The app is not working after an app update in iOS 5.1. The same app is working fine in versions below 5.1.

I explored few things and my analysis is

  1. When we install a app iOS creates a separate sandbox for that and all the data related to that app goes in to that.
  2. in iOS5.1 when we update an app new sandbox is created and the contents from old sandbox is moved here.
  3. For WebSQL ie SQLite for PhoneGap in iOS 5.1 the DB is stored under caches folder(volatile storage). But in previous version of iOS the SQLite DB was stored under Documents folder in Sandbox which is persistent storage.
  4. The real problem is there is a file called ".preferences" in caches/preferences that has the path of websql DB. when i do an app update the sandbox path changes but in this file the previous sandbox is path is still available due to this the app is not working as the previous path is already deleted from device.

Is this an Apple issue or can it be resolved by a developer?

I have fixed the issue by

The path referred by iOS to find WEB DB(SQLite) and Local storage is stored in NSUserDefaults. So when i launch the app every time i check the path information and make sure it matches new sandbox path if not i set the value for that Key and now the app works fine.

NSUserDefault Key referred to SQLite path is WebDatabaseDirectory.

If Apple releases a fix for this issue in their next release, this code is not required.

Try to use cordova-1.6.0 or above this.

When I changed to cordova-1.6.0 , my problem is fixed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM