This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Valid Storage path : | |
NSString* library = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)objectAtIndex:0]; | |
NSString *WebSQLSubdir = (IsAtLeastiOSVersion(@"5.1")) ? @"Caches" : @"WebKit/Databases"; | |
NSString *WebSQLPath = [library stringByAppendingPathComponent:WebSQLSubdir]; | |
NSString *WebSQLDb = [WebSQLPath stringByAppendingPathComponent:@"file__0"]; | |
NSString *WebSQLDbFile = [WebSQLDb stringByAppendingPathComponent:@"0000000000000001.db"]; | |
NSError *attributesError = nil; | |
NSFileManager* fileManager = [NSFileManager defaultManager]; | |
NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:WebSQLDbFile error:&attributesError]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* to use WebSQL or the SQLite plugin (https://github.com/davibe/Phonegap-SQLitePlugin) with the same function) */ | |
executeSqlBridge: function(tx, sql, params, dataHandler, errorHandler) { | |
var self = this; | |
if (typeof self.db.dbPath !== 'undefined') { | |
//Native SQLite DB with phonegap : https://github.com/davibe/Phonegap-SQLitePlugin/ | |
//this is a native DB, the method signature is different: | |
var sqlAndParams = [sql].concat(params); | |
var cb = function(res) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Based on the code of ScottP and Gaurav Tomar ( http://gauravstomar.blogspot.com/2011/08/prepopulate-sqlite-in-phonegap.html */ | |
/* Put that code in AppDelegate.m */ | |
- (void)webViewDidStartLoad:(UIWebView *)theWebView | |
{ | |
NSString *databaseName = @"0000000000000001.db"; | |
//Get Documents path | |
NSArray *paths = | |
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *documentsDirectory = [paths objectAtIndex:0]; |