iphone sqlite3 help

Discussion in 'iOS Programming' started by jagatnibas, Aug 27, 2008.

  1. macrumors regular

    Jul 28, 2008
    I am using sqlite3 in my app. when i use sqlite3_open function to open a db it creates the db. I am trying to open an existing db readonly. what will be the correct function to use ? I tried using sqlite3_open_v2 but got link error

    Moreover I am trying to create a scenario where somr persistent storage [i dont mind files ] will be created by one application and will be used by another application. both the applications will be developed by me. please share any ideas.

    I dont understand the motive behind encapsulating persistent storage. midp does not expose dbs to other midlets, but it exposes the files. i am still ignorant of the advantage of encapsulating the persistent storages and databases.

    I would be happy if anybody can throw some light on this

  2. Moderator emeritus


    Jun 15, 2000
    According to the docs sqlite3_open() only creates the db if it didn't already exist, so I imagine there's something else going on with your code.
  3. macrumors member

    Aug 10, 2008
    Have a look at the SQLiteBooks sample. It shows code for opening an existing database; the steps seem to be making sure the database exists in the project in the first place, and that the command to open it is passing in the correct path. Perhaps you are using the wrong path and therefore it is creating a new database of that name on the iphone in a different directory?
  4. macrumors 68030


    Sep 8, 2003
    The main reason I've seen is that files (and file parsing) does actually provide a vector of attack on apps. In some platforms where you have apps that are allowed full-blown access to parts of the system, and others that aren't, a determined attacker could use the filesystem to execute heap exploits rather than the network.

    There are also privacy concerns if App A has personal information, and App B shouldn't get access to it. Good ACL policies help here, but in the short-term it is easier to just sandbox the app as a whole and be done with it. It also tends to make the APIs managing the sandbox easier as the logic is simpler.

    Regardless of the reasons for why Apple went down the route of sandbox everything from everything else, it is the way it is. If you want persistent storage to be accessible from multiple applications, you will need to use network storage to achieve it.

Share This Page