UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: User data backup

Forums > iOS

My app stores json files and images in the documents directory (local). When the user deletes the app all data is gone too, right? I want to provide a safeguard against that. Some questions related to that?

  1. Will my apps data be backed up with the device backup? If so can the user get the data back after deletion of the app and reinstalling?
  2. should I provide a backup/restore option myself. If so, would it be wise to store that on iCloud (container) ?

Thanks!

3      

Data in the Documents directory does get backed up when iOS backs up the device (either to iCloud or a Mac). This will mean that the user data for the app will be reinstalled if the user has to erase and reset the device, or sets up a new device.

However, this will not persist the data after the app is deleted. Apps have their own sandboxed directories and the Documents directory is deleted when the app is deleted.

You need to use an off-device backup, such as CloudKit (which is excellent, in my opinion), or implement your own if you have your own server and backend.

An alternative is allowing a user to export data to store elsewhere and then import it again, but this relies on the user doing that regularly!

4      

@chriswilson1982 Thank you. I thought as much. Might reconsider putting the app's data on incloud, but I ran into other issues with that (mainly sharing the data bewteen devices, I have another thread on that).

4      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.