मैं का इस्तेमाल किया है का उपयोग करें और मैं देख रहा हूँ कि यह सिर्फ एक दिन पहले अपडेट किया गया। https://github.com/pgsqlite/PG-SQLitePlugin-iOS
उनके यहां एक एंड्रॉइड संस्करण भी है। समस्या का एक हिस्सा है फोनगैप परिवर्तन अक्सर प्लगइन्स को अद्यतित रखने में समय लग सकता है ताकि वे समाप्त हो जाएं। AppDelegate.m में इनिट विधि के लिए कोड यहां दिया गया है I
ध्यान रखें कि आपको कभी-कभी आईओएस सिम्युलेटर को मिटा देना होगा ताकि यह एप्लिकेशन से संबंधित फाइलों को फिर से लोड कर सके।
- (id)init{
NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
int cacheSizeMemory = 8 * 1024 * 1024; // 8MB
int cacheSizeDisk = 32 * 1024 * 1024; // 32MB
अगर __has_feature (objc_arc)
NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"];
बाकी
NSURLCache* sharedCache = [[[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"] autorelease];
endif
[NSURLCache setSharedURLCache:sharedCache];
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;
}
- (शून्य) checkAndCreateDatabase {
// 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];
}
आशा इस मदद करता है ...
कॉर्डोवा के नए संस्करण के लिए मेरा जवाब देखें: http://stackoverflow.com/questions/34673365/working-with-prepopulated-sqlite-database-in-phonegap-android/37857340#37857340 – Balflear