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.
Related
I'm making my first iOS app. And I have a question.In my app I want to save the current state of the app: levels completed, score reached, money, in-App purchases, etc. in a Settings.plist. The problem is, how can I place this plist so that if the user updates the app, he/she not to lose these settings. I read about The app sandbox, but I don't understand
how it works, and how can I manage that from Xcode.
You should store these settings in the NSUserDefaults. They are kept when new app versions are installed, so you won't have any problems.
Two points:
a) When you update your app after its in the app store by submitting a new version of the same app the files created by the old version will not be lost. So you can store whatever you like in the app's Document or Library directories and expect it to still be there after an update. The Library/Caches directory will not be backed up or restored by iTunes so don't put anything there that you can't re-create. If you submit a different version of the app (not an update but a new app, so you have two separate apps in the app store, perhaps free and paid) there is no way that I know of for the new version to get to the files that the first version created.
b) It's easy for the user to read, delete, or change whatever files you create in Documents/ or Library/. It can be done with an app on his/her Mac such as iExplorer (downloadable from macroplant.com). So be aware that if the file is human-readable, which a .plist file is, the user can change it to improve his/her score, get more consumables, or whatever. You can prevent that by encrypting the data, or somehow obscuring the meaning, or by some kind of checksum scheme so you can at least detect that it was changed. Any of those measures involve complications of course and may not be worth the trouble.
BTW... if you're developing an app that uses data files iExplorer is a great debugging tool. I have no vested interest in it except that I've learned how to use it and want it to continue to be supported. There are probably other apps that do the same thing but this one works great and is fast and easy to use.
I have an app that I've built a few months ago and would like to continue upgrading that app.
Since that time, the app has about 6 months of data, and I would like to backup the state of this app before working on upgrading the app (I'm afraid that I will somehow delete/mess up the core data persistent storage if I install a new version of the app.) I do not remember if I got the app from the iTunes store or xCode installation.
I've backed up my iPhone using iTunes and am currently working with an app which has a different app identifier from the production app:
The live app with data I want to save is called "app"
The work in progress version of the app is called "app_test"
There are two versions of the app on the device.
I would like to see how my changes that I've created for the app_test would look on the live production app with real data.
What steps do I need to take to ensure that I can recover my app's data if something goes wrong?
Is it enough for me to change the xcode's project bundle id from "app_test" to "app" to see changes in production?
Thank you for your input, I really value that data and do not want to lose it!
First important point - do not change your "app_test bundle" identifier to "app" - this will overwrite your live app on the phone, and your data will be gone (well, you'll have to restore from backup at least...)
You should be able to use an OSX program such as 'iPhone Explorer' to browse your connected phone - find your app, and see if you can nab the .sqlite file (maybe in the documents or libray folder of your app) - copy it to your desktop.
Now you've got your live database, you have several choices. You could also nab the app_test database, and merge the contents using your favourite sql tools - or import the live .sqlite file to your app_test xcode project, and tell app_test to use that as the data source.
If you need write access to the database, you'll have to copy the live .sqlite from your app_test bundle to the documents or library folder first.
I want to store a date string in the iphone device, but not in the application context, because if a user deletes the app then that value is deleted too.
Is this possible?
Store it in the keychain. Keychain data is not deleted when the app is.
A possible solution is to store all the information on a server. You could use rails, php, or any other server framework to do this. Also, there's a new service that's trying to make it so you don't have to do any server coding at all: http://www.parse.com
If the application gets deleted on iPhone, all its related files are also deleted. Including files, SQLite databases and preferences.
If you want preference to persist after deletion, you will need a server and allow the user to store that information there (in the cloud).
i want to save a file outside of my application bundle as a backup of database so that when user reinstall my app or my app crashes he can backup his data from that location.
Apple already does this, with iTunes.
What you are asking is technically against apple's policy, unless you store it off site, on a server (which you could easily do)
If you have a lot of applications, I'm not aware of the policy, but perhaps you could make an app to back up your other app's data.
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.