Reputation: 23
I am using UIWebView in a regular Objective-C iPhone App. Web pages displayed in the UIWebView are writing to a HTML5 client-side SQL database via javascript. I would like to open this database for reading and writing from the iPhone App. Is this possible? and if so, how do I find the database and can I use the SQLite framework to open them?
Upvotes: 2
Views: 1999
Reputation: 31
The SQLite databases used by the UIWebView
's WebKit instance are actually in <Application_Home>/Library/WebKit/LocalStorage/file__0/
, e.g. 0000000000000001.db
.
Upvotes: 2
Reputation: 283
Old question but I found this while Googling on the subject and thought I'd update it with the solution.
The localstorage databases are sqlite databases and are stored in <Application_Home>/Library/WebKit/LocalStorage and the database for your app will be something like file__0.localstorage
You can get the path to the file with something like this:
NSString* fullPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/WebKit/LocalStorage/file__0.localstorage"];
Hope this helps anyone else who's looking into this.
Upvotes: 0
Reputation: 187114
I don't think its exposed in this way.
First, I don't think UIWebView
s will have a client side database that persists across multiple sessions (although it might, I haven't tested it). And second, it certainly doesn't give you direct access to the SQLite database file itself.
Your best bet would be call javascript into the webview with
[webView stringByEvaluatingJavascriptFromString:@"mySqlQueryingFunction()"]
letting javascript access the database for you.
Upvotes: 2
Reputation: 360
The HTML5 database lives outside your app's sandbox and can't be accessed directly. If you have control of the web pages being displayed in the UIWebView you can build a relatively simple javascript bridge to fetch the contents and insert them into your own SQLite DB.
Upvotes: 0