Application data stored in Library/Caches being persisted across app installs - ios

I have some application state data that I am storing in the Library Caches folder, and have been noticing when I delete the app from my device, then build and run the app again, the same file exists.
Is this just a symptom of debug development or does this behaviour actually occur in production? Where else am I to store such files if I really want them to only exist per installation?

Related

IOS: Data persistence between versions of the app

I cannot find any information on topic: what is happening when I release new version of iOS application on iTunes? Is older version on device completely replaced? Or there is a persistence of Documents folder?
Is it possible to make update to be like a "clean" installation?
When you release an update to your iOS app and the user installs it, the system does not wipe out any data from within the app.
This means that data in a given user's Documents directory, NSUserDefaults, as well as the keychain will persist between app updates.
A couple of important notes, however:
The Caches directory of an app is never reliably persisted, so if you want to make sure data stays safe, don't put it in this directory
Items in the keychain seem to persist even if you completely erase the app and re-install it. I've noticed this in the past, so it may be a good thing to keep in mind
In short, if you want data cleaned out of your app on each update (not sure why you would), you'll have to do so manually.
Your Documents folder will not be cleaned.
If you want to clear it, make sure to do it programmatically in your new release.
The Documents folder is deleted only when the user deletes the app.

iOS Remove sqlite after uninstall app

I have an App developed in XCode, the DataBase was made in Sqlite, but when I remove the app from my iOS device, I lost all the information from that DB.
When I install the App again, I have the DB but without information inside.
Can I keep that file.sqlite (in a cloud)? And when app is reinstalled (download) to use the same file.sqlite and to have the data that I had before in that file.
No you cannot keep the file.sqlite on the filesystem after your app is uninstalled. As soon as the app is uninstalled the associated data file is also deleted.
You should be able to solve this by synchronizing the SQLIte database with another database stored in the cloud. If you associated the synchronized records with a user account, the next time they use that user account, you can refresh the local database with the server database. It won't matter if they deleted the app or moved to a new phone. You're storing their backup on a server.

Where do I properly place sqlite database so it wouldn't get removed on app update from appstore?

I am frightened to release my app using this technique to put the database on NSDocumentDirectory. what if I put on an update? will it get removed? users of the app might get really annoyed when the database will get overwritten and clear its contents?
do you think im doing it right?
https://developer.apple.com/library/ios/DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/PerformanceTuning/PerformanceTuning.html
Files Saved During App Updates
When a user downloads an app update, iTunes installs the update in a
new app directory. It then moves the user’s data files from the old
installation over to the new app directory before deleting the old
installation. Files in the following directories are guaranteed to be
preserved during the update process:
<Application_Home>/Documents
<Application_Home>/Library
Although files in other user directories may also be moved over, you
should not rely on them being present after an update.

iOS app submission - what happens with LocalStorage

What happens to data stored in local storage when you release an iOS app update. Is it wiped completely or will it still all be available?
When a user downloads an application
update, iTunes installs the update in
a new application directory. It then
moves the user’s data files from the
old installation over to the new
application directory before deleting
the old installation. Files in the
following directories are guaranteed
to be preserved during the update
process:
<Application_Home>/Documents
<Application_Home>/Library
Although
files in other user directories may
also be moved over, you should not
rely on them being present after an
update.
You should check http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html in the Performance Tunning section for more information!

Is it possible to retain data of the older version if a new version of app is deployed on device?

I am new to iOS development so my question may be n00bish.I am working on an app for iPad which downloads PDFs and stores on the device(iPad) in the Documents directory so the user can still read them if he isn't connected to WiFi. My question is:if a newer version of the app is available and the user installs it, will it delete all the data(documents,in this case) from the device? If yes,how do I prevent the old data from being deleted? I am using CoreData in this app(if this helps)
When a user installs an updated version of any app, the app's sandbox is kept intact. Only the app and its resource bundle are replaced. So basically, anything you have stored in Documents or Library will be kept intact after the update process. There is no guarantee that files in Library/Caches or tmp will be kept but those should only have transient files anyway.

Resources