0

I tried sqlite FMDB but it must store database into separate file I want solution that the database file is the same executable file ie they are bundled together into one app please help

Ven
  • 19,015
  • 2
  • 41
  • 61
  • You can include a file in your app bundle, but you wouldn't be able to save it. Is it read only? – danh Dec 01 '14 at 18:18
  • yes it is read only. how to include it into my app bundle? please help – Alaa Ahmad M. Zakaria Dec 01 '14 at 18:20
  • Somebody smarter may have a better answer, but I would write the file I want to ship to documents directory on simulator. Then go find that file in finder (see here http://stackoverflow.com/questions/6480607/is-there-any-way-to-see-the-file-system-on-the-ios-simulator). Drag that file into your app in Xcode. – danh Dec 01 '14 at 18:25
  • I need the database file to be included into .app file i tried dragging the file into xcode directory but it didn't work. you have to specify a path for database file – Alaa Ahmad M. Zakaria Dec 01 '14 at 18:33

1 Answers1

1

Here's how to do it: create database with a file handle for the file system produced in the traditional way (NSSearchPathForDirectoriesInDomains and stringByAppendingPathComponent: @"mydb.sql").

Sounds like you've got that done. Drag the resulting file into your app. Once in your app bundle, the way to get at the file is like this (using the filename I made up above):

NSString *fileName = [[NSBundle mainBundle] pathForResource:@"mydb" ofType:@"sql"];
// or whatever you called the file in your bundle, use ofType: as the filename's extension

That should suffice as input to the FMDB package.

danh
  • 62,181
  • 10
  • 95
  • 136