objective c - iPhone: Where is my Sqlite database? -


i can't find sqlite db. i'm using 4.1 simulator.

all tutorials it's @ /users/<username>/library/application support/iphone simulator/4.1/applications/<app>/documents. there's nothing there. how create new 1 code? see .sqlite file here?

in code doing this:

int result = sqlite3_open("/myapp.db", &database);  if(result != sqlite_ok) { sqlite3_close(database); nslog(@"failed open db"); return; }  else { nslog(@"opened db"); } 

i proceed create table, , query , both of them succeed.

yet, can't find sqlite file it's putting data at.

where possibly be?

below there 2 function

  1. first 1 copy database if not in app during installing in ur emulator.

2.second function path of database.

these 2 functions must call in - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions delegate function in yourappdelegate.m database copy application folder of emulator if not present there.

don't forget add

nsstring *databasepath; sqlite3 *contactdb; 

in yourappdelegate.h

- (void) copydatabaseifneeded {      nsfilemanager *filemanager = [nsfilemanager defaultmanager];      nserror *error;      nsstring *dbpath = [propertyuploaderappdelegate getdbpath];      bool success = [filemanager fileexistsatpath:dbpath];      if(!success)       {  nsstring *defaultdbpath = [[[nsbundle mainbundle] resourcepath]   stringbyappendingpathcomponent:@"yourdatabasename.sqlite"];  success = [filemanager copyitematpath:defaultdbpath topath:dbpath error:&error];          if (!success)              nsassert1(0, @"failed create database file message '%@'.", [error localizeddescription]);      }  }   +(nsstring *) getdbpath {      nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory , nsuserdomainmask, yes);      nsstring *documentsdir = [paths objectatindex:0];      return [documentsdir stringbyappendingpathcomponent:@"yourdatabasename.sqlite"];  } 

after these process check in /library/application support/iphone simulator/4.1/applications/<yourappfolder>/documents


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -