We are transitioning away from PhoneGap to a truly native iPhone app and we need to access user data stored in HTML5 local storage created by PhoneGap. How do we get at that data so that we can create a seamless update process for the user?
I haven't tried Mattias' way but I just accessed the webkit local storage database directly and then imported the sqlite3 lib included with the iPhone SDK to extract the values I needed. This is how you access localstorage created by PhoneGap:
NSString *databaseName = @"file__0.localstorage";
//Get Library path
NSArray *libraryPaths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSUserDomainMask, YES);
NSString *libraryDir = [libraryPaths objectAtIndex:0];
NSString *databasePath = [libraryDir
stringByAppendingPathComponent:@"WebKit/LocalStorage/"];
NSString *databaseFile = [databasePath
stringByAppendingPathComponent:databaseName];
BOOL webkitDb;
NSFileManager *fileManager = [NSFileManager defaultManager];
webkitDb = [fileManager fileExistsAtPath:databaseFile];
if (webkitDb) {
MMWebKitLocalStorageController* wkc = [[MMWebKitLocalStorageController alloc] init];
[wkc updateUserFromLocalStorage:databaseFile];
}