user1660882
user1660882

Reputation: 291

constraint issue in sqlite

i am creating database in sqlite i create new database with constraint notnull and unique and save it to the place where is my application then i add things from my application and i check them in Library, Application support/.../..../... when i check database which is just created there then there this database is without Constraint and it accept same data.

why this is happening?

how can i make this database with Constraints just same like i have created while making application database

yes i have tried deleting database and making again

plz suggest something

Upvotes: 0

Views: 78

Answers (1)

Rob
Rob

Reputation: 437682

One of two problems generally causes this sort of behavior (where you're updating a database and you're not seeing this propagated to the app):

  1. The db in the bundle is not getting updated. You can check this by running app on simulator, opening bundle (go to the app in Finder, ~/Library/Application Support/iPhone Simulator/..., and select the app itself and choose "Show Package Contents"), and examining the db directly at that location. Bottom line, Xcode sometimes does not update the bundle properly for files altered outside of Xcode itself. This is fixed by selecting "Clean" from Xcode's "Product" menu, and then rebuilding and reinstalling the app.

  2. The db that app is loading is not a copy of the version in the bundle. It doesn't sound like this is your problem, but many first time developers will copy the db from bundle to Documents folder if the file is not already there, neglecting to remember that when you install the app again, the contents of the Documents folder is preserved, and thus you'll still have the old version there. Just uninstall the app or reset the simulator if you're trying to address this for testing purposes.

    Longer term, the app itself needs some logic that looks up the version number of the database (I create a "configuration" table with this information) in the Documents folder, compares that to what version the app expected to find, and if different, upgrade the database in the Documents folder.

Bottom line, it's useful to check all three databases (project directory, bundle, and app's Documents folder) to see at which step you lost your database changes.

Upvotes: 1

Related Questions