I did some research about backup files and data in iCloud and I was wondering if the Core Data would get saved in an iTunes backup if i would not use any iCloud functionality.
So i got an application with recent server connections saved in core data to fill it back into a UITableView. If i make a device backup with iTunes and restore it later on another device would the recent connections still show up?
None of the Q/A I found did explicit answer this question.
Another question besides: Is it possible to try these itunes-backup things with an app which is in developement?
This depends on where you save your core data database.
In general the Library and the Documents directory are backed up by iTunes (and by iCloud), tmp and Caches are not backed up.
See: Apple Documentation - iOS Standard Directories: Where Files Reside
AppName.app
This is the app’s bundle. This directory contains the app and all of its resources.
You cannot write to this directory. To prevent tampering, the bundle directory is signed at installation time. Writing to this directory changes the signature and prevents your app from launching. You can, however, gain read-only access to any resources stored in the apps bundle. For more information, see the Resource Programming Guide
The contents of this directory are not backed up by iTunes. However, iTunes does perform an initial sync of any apps purchased from the App Store.
Documents/
Use this directory to store user-generated content. The contents of this directory can be made available to the user through file sharing; therefore, his directory should only contain files that you may wish to expose to the user.
The contents of this directory are backed up by iTunes.
Documents/Inbox
Use this directory to access files that your app was asked to open by outside entities. Specifically, the Mail program places email attachments associated with your app in this directory. Document interaction controllers may also place files in it.
Your app can read and delete files in this directory but cannot create new files or write to existing files. If the user tries to edit a file in this directory, your app must silently move it out of the directory before making any changes.
The contents of this directory are backed up by iTunes.
Library/
This is the top-level directory for any files that are not user data files. You typically put files in one of several standard subdirectories. iOS apps commonly use the Application Support and Caches subdirectories; however, you can create custom subdirectories.
Use the Library subdirectories for any files you don’t want exposed to the user. Your app should not use these directories for user data files.
The contents of the Library directory (with the exception of the Caches subdirectory) are backed up by iTunes.
For additional information about the Library directory and its commonly used subdirectories, see The Library Directory Stores App-Specific Files.
tmp/
Use this directory to write temporary files that do not need to persist between launches of your app. Your app should remove files from this directory when they are no longer needed; however, the system may purge this directory when your app is not running.
The contents of this directory are not backed up by iTunes.
Related
This question may not be related to programming
An application will generate a large folder under /Users/Library/Containers/com.xxx.xxx during initialization. I want to move it to an external drive, but the app crashed after I ln -s back the folder and ran the app, which may be related to data verification or some plist files in it.
Is there any solution?
I am building an app for windows store and I need some default and example data to be in the localstate folder (Windows.Storage.ApplicationData.current.localFolder) when the app run the first time.
The folder and files structure is a bit complex and I tryed to copy the files at the start of the application, but I can't manage that way.
Is it possible to have files being copied automatically from the installation folder to the localstate folder during the store app installation?
Unfortunately, customization of the app install process isn't currently supported. You have to do this as part of your first run processing.
One possibility is that you include the data in your package as a .ZIP or other compressed file and use an appropriate library to expand that file into a folder structure on startup. That could simplify your logic considerably. (I don't have a library to recommend; it's just an idea.)
I have a jailbroken iPhone, is it possible to take a zip of the entire application directory (e.g. /private/var/mobile/Applications/{UID}) and then use that zip to install the application?
Ultimately, I'm attempting to save the state of this application so I can run tests, and then return it to this state.
Yes, you can do this.
Assuming that the entire state of your application is saved in places like the Documents, or Caches folders, or in app preferences (NSUserDefaults).
You can make a zip of /var/mobile/Applications/{UID}, ssh/scp that .zip file back to your computer (or store it elsewhere on your iPhone), and then unzip it later.
Depending on whether you move the app (install it in a different location), or completely delete it at some point, you may need to refresh the list of apps after you restore (unzip the .zip file). You can do that either by rebooting, respringing (restart SpringBoard), or ssh'ing into the device and issuing the uicache command:
ssh mobile#iphone uicache
Note: I think you understand this based on your question, but you do need to zip up the whole /var/mobile/Applications/{UID}/ directory. Not just the MyAppName.app directory under it. That's because, for example, of where the data, user defaults plist, etc. are stored. If you are concerned about the speed of your backup and restore operations, or disk usage, you could probably try to narrow down which files you backup (e.g. ./Documents/ and ./Library/) ... I'll leave that to you.
I have created the application which is based on Sqlite database.
So in my app, initially i have created the Sqlite db with one data and i have added that db into my "Resource" folder in my project.
While app running at first time, checking db in Documents folder(Sandbox) if no file means, copy the db from Resource to Document folder.
After that every insert and delete operations performing on Db in Document folder only. not on db in Resource folder.
So, i have inserted 50 items in db and then i have deleted the app from Simulator(or) device.
When deleting app, db also deleted with that.
My question is ==> How to overwrite the Sqlite db(in Resource folder) with db(in Documents folder) when every updation in app(insert, delete)?
because db file in Documment folder getting update while inserting items into that.
I am using XCode 4.2 with iOS 5 sdk.
You cannot change the Resource bundle once you created (i.e app file). You cannot overwrite the SQLite db into resource folder of your bundle.
If you still want to keep previous db then just copy it from simulator path and replace whenever you clean and build the app.
EDIT:
You can go to /Users//Library/Application Support/iPhone Simulator/"Simulator version you use"/Application/"check all folder to find your app inside this folder"/ "YOUR APP.app"
Then Right Click APP file and Click Show Package Content. Now you will be able to see the resources you used in App file. You can search your DB and BACKUP/REPLACE it.
First off the database file in the app bundle (resource folder) is read only and can't be changed by the app.
Second when an update is installed, all the files in the app bundle get replaced by the files in the update. The files in the document directory aren't touched.
if you need to update the database file in the document directory you will need to implement an update method some where and keep track of the versie of the database used.
There is no way you can modify any resource present inside the application bundle.That's why we copy the database file to the documents directory of the application, so we can modify the file. If you want to preserve data, you backup the data using the iCloud service.
You have to do this by opening another handle for the database in your resource folder and perform the operation for that too. I assume you need it only when you run it in simulator for convenience.
You cannot do this when you run in device.
Its true that there is no way to copy that document folder data again to resource bundle, so i will suggest u to take a backup of that db before deleting the application from simulator or from the device.
I have a lot of jpeg+png+html files to add to my app, and of course when i "build" it all my resources files are added/included in myApp mainBundle folder.
I'd like to be able to modify via code, in run time, some of my resources, but:
1) we cannot "write" files via code in run-time in mainBundle
2) we can do it just in "documents" folder (or temp, or...)
3) we can copy files in "Documents" folder just via code in run-time
4) we cannot delete the mainBundle files after coping them in "Documents"
but that means that we will have doubled-sized our app, and in big apps (it's my case) this should be a non-sense, we'll have a lot of big files never used again in the mainBundle...
so i wondered if there was a work-around for this problem (is it just me thinking it's a non-sense?) to add files directly in the "Documents" folder in the "build" phase via xCode, or other similar solutions...
ps
one could be to download all files the first time a user use my app via server/internet directly in "Documents" folder, so my app won't be heavy to download via iTunesStore, but of course this will get a lot of time the first time for end-users, and it could be not well accepted, of course...
Well you can't, since the document directory is created on installing the app. There is no way to do what you want on compile time. Neither you can do it at the install.
Since you needed the file you have to include them in your bundle, i've even included 10MB sqlite database that I copy to to the document direct on first launch. That is just the way it is.
Doesn't work for apps
Copying files to the documents directory during compile time requires you to know that directory in advance. You generally can't know this as the documents directory might not have been created before your app is installed.
Can work for unit tests on the simulator
However, the location of the documents directory depends on the target platform and the kind of bundle you are building. For unit tests based on SenTestingKit executed on the iOS simulator, you can determine the documents directory at compile time by just doing this inside a "Run Script" build phase:
~/Library/Application Support/iPhone\ Simulator/$IPHONEOS_DEPLOYMENT_TARGET/Documents
Note that this really only works for unit test bundles as those are not executed in a dedicated app directory and thus access a "shared" documents directory on the simulator platform.