First create database as u used name data_items.sqlite and remove .sqlite extension. Then drag this db at Resources directory in xCode and follow next .
Choose option for adding file box will appear
check checkbox says 'Copy items into destination group's folder (if needed)' and finish.
You will see the Database file as sub list of Resources Directory
Sorry I don't have enough reputation to post images here
Now follow the link to copy this database file into location
How to copy sqlite database when application is launched in iOS?
I used the following code before the @end at last line in AppDelegate.m
- (void) copyDatabaseIfNeeded{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
_dbPath = [self getDBPath];
BOOL success = [fileManager fileExistsAtPath:_dbPath];
if(!success){
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"data_items"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:_dbPath error:&error];
if (!success)
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}}
/********* Database Path *********/
- (NSString *) getDBPath
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *documentsDir = [paths objectAtIndex:0];
return [documentsDir stringByAppendingPathComponent:@"data_items"];
}
And Copy the line
[self copyDatabaseIfNeeded];
after the code
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
CGRect screenBounds = [[UIScreen mainScreen] bounds];
That's it. Use your code
function onDeviceReady() {
var db = window.sqlitePlugin.openDatabase("data_items", "1.0", "data_items", 200000);
...
}
You can also edit database directly in from the copied location. Use following link
Where does the iPhone Simulator store its data?