Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have used the following plugin for Cordova 2.7 with iOS6 and I see it was just updated a day ago. <a href="https://github.com/pgsqlite/PG-SQLitePlugin-iOS" rel="nofollow">https://github.com/pgsqlite/PG-SQLitePlugin-iOS</a></p> <p>They also have an Android version here as well. Part of the problem is PhoneGap changes so often keeping plugins up to date can be time consuming so they lapse. Here is the code for the init method in the AppDelegate.m I use in this project <a href="http://www.binpress.com/app/conference-core-ios-for-phonegap/1483" rel="nofollow">http://www.binpress.com/app/conference-core-ios-for-phonegap/1483</a></p> <p>Keep in mind that you sometimes need to wipe the iOS Simulator so it reloads the files related to the application. </p> <pre><code>- (id)init{ NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; int cacheSizeMemory = 8 * 1024 * 1024; // 8MB int cacheSizeDisk = 32 * 1024 * 1024; // 32MB </code></pre> <blockquote> <h1>if __has_feature(objc_arc)</h1> <pre><code> NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"]; </code></pre> <h1>else</h1> </blockquote> <pre><code> NSURLCache* sharedCache = [[[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"] autorelease]; </code></pre> <blockquote> <h1>endif</h1> <pre><code>[NSURLCache setSharedURLCache:sharedCache]; </code></pre> </blockquote> <pre><code>databaseName = @"SomeCoolDatabase.db"; NSLog(@"databaseName: %@", databaseName); databasePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0]; NSLog(@"databasePath: %@", databasePath); databaseFile = [databasePath stringByAppendingPathComponent:databaseName]; NSLog(@"databaseFile: %@", databaseFile); // Execute the "checkAndCreateDatabase" function [self checkAndCreateDatabase]; self = [super init]; return self; </code></pre> <blockquote> <p>}</p> <p>-(void)checkAndCreateDatabase {</p> </blockquote> <pre><code>// Check if the SQL database has already been saved to the users phone, if not then copy it over BOOL success; // Create a FileManager object, we will use this to check the status // of the database and to copy it over if required NSFileManager *fileManager = [NSFileManager defaultManager]; // Check if the database has already been created in the users filesystem success = [fileManager fileExistsAtPath:databaseFile]; // If the database already exists then return without doing anything if(success){ NSLog(@"Database Present"); return; } else { NSLog(@"database not present"); } // If not then proceed to copy the database from the application to the users filesystem // Get the path to the database in the application package NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName]; // Create the database folder structure [fileManager createDirectoryAtPath:databasePath withIntermediateDirectories:YES attributes:nil error:NULL]; // Copy the database from the package to the users filesystem [fileManager copyItemAtPath:databasePathFromApp toPath:databaseFile error:nil]; [fileManager release]; </code></pre> <blockquote> <p>}</p> </blockquote> <p>Hope this helps...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload