Sqlite database is not updating - iphone

Hi am new in this field.i am trying out one app.
i am storing data in sqlite database. i am only using sqlite for my app when i add data into table from my app, I can see changes in my simulator but when i check my database there is no change and when i reset my simulator all my added data is gone. Please help me. i don't know what is wrong. there is no error.

When you say "reset my simulator" does that mean quit the app and restart it, or use the "Reset Content and Settings" option from the iPhone Simulator menu?
Doing the latter will erase all simulator apps' data, but doing the former should not.
How and where are you creating the database file that you intend to write to?
The correct thing to do is generally the following:
Put an empty copy of the database (probably with necessary tables created and any initial data already entered) in your app's bundle.
On app launch, check for the existence of the database file in your app's Documents directory. If it doesn't exist, copy it from the bundle to Documents. If it does exist, do nothing.
Your app should write to the copy of the database in your app's Documents directory. This means that the database in your app's bundle will (and must) stay the same, but the one in Documents will contain any new data.

Related

Will sqlite database be port over to iTunes when iphone app got sync

I was wondering whether my app's sqlite database will be transfer over to desktop when user sync the app with iTunes or do I need to do some coding to ensure that it will be transferred?
Please advice. Many thanks.
You can transfer the content of your document directory's document folder contents by adding UIFileSharingEnabled key to your info.plist.
Please check the below image:
After adding this key to your info.plist, when you sync your iPad with iTunes the documents inside the document folder will be listed in iTunes as shown below:
This is a nice tutorial for starting the iTunes filesharing: How to integrate iTunes file sharing
We not only can backup our files on itunes but also in icloud....
this is how the app data is persisted along the the app updation ,ios upgradation....
As you long you put your data files in standard locations within the app's sandbox and you don't explicitly flag the file as a file that shouldn't be backed up, then the data files will be backed up to iCloud or iTunes (depending on how the user has setup device backups).
It depends on your file scheme, you can decide which information is necessary and should be backed up and which one should not because it can be easily recreated.
Look for the "Where You Should Put Your App’s Files" section
http://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW2

How to make a backup of my app (iPad)?

i am new in programming and have some troubles with backup.
I have an App with SQLite database and different user params in it. All data will be saved, after I leave application. But if I reinstall it, all data is lost.
So, i think i need some kind of backup for this data. I mean is there any way, how to save SQLite db outside of apps folder?
Updating the application will not overwrite your data, but deleting the app will remove all data. You don't need to delete the application each time you redeploy to your device or simulator.
Your application doesn't have access to anything outside of it's sandbox, so saving outside the apps folder is out of the question.

Contents of SQLite dbase on iPhone are deleted after crash

I have this weird problem where I lose my data after a crash.
What happens is the following:
I insert a product in the app -> product is saved to the sqlite database.
The app crashes. At this moment the product is still in the database (I double checked this on simulator and iphone device with ftp to get my sqlite database off my phone.)
At the moment of reinitiating my app, the contents of the sqlite are removed. And an empty sqlite with the same tables etc is replaced.
I wonder why and how to fix this problem.
Thanks in advance,
Lewion.
I presume on start-up you're checking for the presence of the database in your document directory and copying a "clean" copy from your bundle if none is present.
Are you sure the problem doesn't lie in the logic you're using there?

How can i check update database in core data

Hi I am new in iphone app, i am just trying out some apps.
I am trying to add more data in my database, i just want to see where it is stored and my database updated or not.
The default for the template projects is that it will save a file named "NameOfProject.sqlite" into the apps document folder.
On the simulator, the app's directories will be in:
(user's home directory)/Library/Application Support/iPhone Simulator/(build iOS version number)/(UUID string)/
The text in the "()" varies.
For example, one of my projects has a path:
(my home directory)/Library/Application Support/iPhone Simulator/3.2/Applications/2E211069-AEF3-4F1F-9CA2-A18EF310F798
The name of the app's directory is a UUID and often changes so you have to constantly check.

SQLITE no such table: error IPhone

Im have been using sqlite as a store in my app and everything was going fine problem is i changed my database schema deleted the old one and then inserted the new one in and now the application no longer loads any data despite all of the sql statements working fine whenever i run them in the firefox plugin. I have done a build clean and reset the simulator as well as delete the app in the simulator does anyone have any ideas whats going on?
-Have you copied the new database to the documents directory in the appdelegate?
-After deleting the app from the simulator, and do a clean all, it should copy the database to the app's documents directory. Or if you won't change the database, you can delete the old and copy the new one every start.