I am currently in the process of developing a mobile application using Phonegap version 1.4.1. I have encountered an issue on iOS (running on version 5.1) where the app fails to load all data from localStorage.
Upon first use of the app, I set a flag in localStorage like this:
window.localStorage.setItem("myFlag", "true");
Additionally, I set items "ItemA", "ItemB", and "ItemC" in a similar manner. These key/value pairs are added at different points during app usage, so their order of setting is not predetermined.
The issue at hand:
Upon reinstalling the app without deleting the current copy first, the app no longer recognizes "MyFlag", "ItemB", or "ItemC" - however, it does still recognize "ItemA". When checking window.localStorage.length
, it returns 1 instead of the expected 4. I have exported the app's data files and inspected the file__0.localstorage with SQLite Inspector (available on the app store), which displays all four key/value pairs.
Due to iOS 5.1+ relocating local storage to the Cache folder, I have incorporated a backup procedure for the file__0.localstorage as outlined here. Essentially, this process involves copying the localstorage database to the Documents folder upon app pause or exit, and then reverting it back to the Cache folder when webViewDidStartLoad is executed. This backup mechanism is functioning correctly, leading me to believe that it is not the cause of the problem (as the symptom was present prior to implementing this procedure).