Skip to content
Iris Edge StudiosIndependent game studio

Iris Edge Studios/ Guides/Engineering

Engineering

Saves that survive a reinstall and a new phone

A daily game asks for a commitment measured in months. Break that and no patch notes will fix it.

Three separate failures

"Losing a save" is really three different bugs, and they need three different fixes: the write that got interrupted, the reinstall, and the new phone.

The interrupted write

The naive save is one file, opened, truncated, written. If the process dies between the truncate and the write, and on mobile it can, the file is now empty and the player's progress is gone.

The fix is an atomic write: serialise to a temporary file, flush it, then move it into place. A move within the same filesystem is atomic, so the save file is either the old version or the new one and never a half-written one. Keep the previous version as a .bak and fall back to it if the primary fails to parse. Pinteza does this for every save through a single SafeFileIO helper, because the moment two code paths write files two different ways, one of them is wrong.

The reinstall and the new phone

Local files do not survive an uninstall. What does survive is the operating system's own backup: iCloud on iOS, Auto Backup on Android. Both are free, both are tied to the player's own account, and neither needs you to run a server or ask anyone to make an account.

On Android this needs an explicit backup rule in the manifest. Ship without one and Auto Backup's behaviour is not what you would guess. Test it properly: install, play, uninstall, reinstall, and confirm the progress is there. Not once, on one device.

The trap in restoring

Cloud restore creates a bug that does not exist locally. If any entitlement is written into a file the OS backs up, a restored backup grants that entitlement on the new device for free. Anything a player paid for must be read from the store's own receipt on every launch, and never persisted into a backed-up save. The source of truth is the store, not your file.

The mirror of this: cached state must be invalidated when a restore lands. A restored inventory that the game has already cached in memory will be ignored and then overwritten by the stale copy, which looks exactly like the restore silently failing.

Versioning, before you need it

Every save is a wrapper with a version number, from the first release. Not because the schema will change, but because it will, and adding a version field to files that are already on players' phones is a much worse afternoon than having had one all along.

What to actually test

  • Kill the app mid-write and relaunch.
  • Fill the disk and try to save.
  • Uninstall, reinstall, confirm progress returns.
  • Restore a backup onto a device that has never run the game.
  • Restore a backup that contains a purchase, and confirm the entitlement comes from the store rather than the file.

More guides