iPhone SQLite Database not updating - iphone

I just updated my sqlite database (added some new records) - saved it, reimported it into my Xcode project, and re-ran my app - all the new data showed up perfectly well on the iPhone Simulator as expected.
However, after installing the app on my iPhone, I'm still getting the old data that was bundled with the previous version of the app.
I of course deleted the older version of the app from the iPhone first, assuming it would thereby destroy its "Documents" folder and the older db file that was in it - but for some reason its still reading (or displaying) the old data - which doesn't make sense. Any ideas?

Try rebooting your device after you make database changes, and then seeing what sort of results you get.

Related

Core Data Appears to Lose Data After Xcode Upgrade

For the second time, my core data app has "lost" (explanation below) the data. I'm not positive this has to do with the update of Xcode, but I did update to 9.4 today (I don't remember whether there was an update involved the last time this happened). I entered data yesterday, then closed the app, re-opened the app, and everything was fine; all the data was there. Today when I opened the app, there was no data. My app prints out the location of the database (print(container.persistentStoreDescriptions)), and when I look at the sqlite file there it has 25 kB.
Searching through the ridiculously deep folder path, I found a file that said it was modified yesterday, and when I look at the sqlite file there (with DB Browser for SQLite), the data is all there (also 25 kB). It seems as if Xcode has forgotten where it put the data. Has anyone else experienced this?
How would I go about fixing this? I guess I could copy the SQLite database from where it actually is to the place Xcode thinks it is (the other files there also, .sqlite-shm and .sqlite-wal?).
after the update of Xcode, the device that initially ran was iPhone 8, whereas, I had been running it on an iPad simulator before the update
Each simulator gets its own folder with its own sqlite files. So if you want to see the data that was in the iPad simulator before, you need to run the same iPad simulator from the new Xcode. If you copy sqlite files from one simulator folder to another, be sure to copy the -shm and -wal files too.

Problem in updating app on iPad

I created an app for iOS 3.2 for the first version 1.0.
Recently I created an updated app for iOS 4.2 with print feature etc. for the second version.
My problem is that, the users are not able to update the app from appstore.
They are facing issues like data loss of version 1.0 app, crashing etc.
Can someone explain me what can be the reason for this?
And, how can I test this thing on my device, as I am not having the version 1.0 app from appstore, but the code for both versions.
Delete your new one on your test device and install the old one. Then build and debug the new one line by line. I had lots of trouble my first time through due to confusion over the update/migration process of core data. If you use core data, chances are your existing customers have an out of date store DB that your new code is crashing on. The store doesn't get wiped in an update if it's in your user's document directory... Only the one in the app bundle. You'll need to handle that reset or tell core data to migrate it to the new model. Of course, all this is speculation since you've given almost no details about the problem, frameworks used, log files, etc.
During a normal install process, data should not be overwritten. NSUserDefaults and files should remain during an upgrade, as long as the user doesn't delete the app first. I assume the crashing occurs after the new version is installed?

Iphone SQLite problems

I'm developing an iphone application that read data through the sqlite.
I created a database through Terminal and added to the Xcode project.
I went back to the terminal and includes a new table in the file. sql. The problem is because my new queries do not see the new tables. This is kind a cache? How do i solve this problem?
Where is the SQLite file? Is it in your application bundle? Make sure you modify the version that's been copied to your iPhone Simulator folder (~/Library/Application Support/iPhone Simulator/) if you’re trying to modify the version running in the simulator.
What code do you use to create the database? Are you checking to see if it exists before copying it to your documents folder? If so, it exists and won't be copied.
You might try uninstalling your app from the simulator (or device) and reinstalling the app presumably with the new SQLite database. There's a few ways to get the old database in this situation.

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.

How can simulate the IPhone app upgrade process in the SDK simulator

I'm working on an iPhone app and about to release version 2. We'll be changing the core data model and I'd like to simulate the upgrade process in the simulator before releasing it to users and potentially causing data loss for them. There doesn't seem to be any real good doucumentation on how to do this in a sandbox before releasing it.
The process I've used in the past has been to wipe any working version from the Simulator, check out the previous version of my application from my repository, compile and install that, work with it for a bit, then compile and install the new version of the application. The installation of the new version should simulate the upgrade process, where you can test your data migration to your new model.
I also repeat this process on the device to make sure no problems are encountered there either.
there are some cases that cannot be simulated in Xcode. Look at this Apple page: https://developer.apple.com/library/ios/technotes/tn2285/_index.html
You have to create IPA file and simulate update via iTunes.
I agree with Brad's overall approach. To save a little time, I would just save the sample set of data that you create with the older version of your app. This way you won't have to keep recreating the sample data set if things don't go right. You will just simply copy the sample data set back into your app's directory in the Simulator.
Your app's directory is located at ~/Library/Application Support/iPhone Simulator/User/Applications/A GUID for your App on your development machine.