PDA

View Full Version : iphone sqlite3 help




jagatnibas
Aug 27, 2008, 07:28 AM
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

regards
Jagat



kainjow
Aug 28, 2008, 04:03 AM
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.

beachdog
Aug 28, 2008, 08:57 AM
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?

Krevnik
Oct 5, 2008, 03:57 PM
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


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.