Simon Hutton
Simon Hutton

Reputation: 1787

How do you persist image references across app updates on iOS devices

I have developed a Flutter app that captures images using the camera and I store references to the image files using Shared Preferences.

When I upgrade the iOS app, the Shared Preference filename persists as expected, but the image no longer displays on the iOS device (and no longer seems to exist) File(_imageFileRef).existsSync() is false

For example, on iPhone, the image file is saved as

/private/var/mobile/Containers/Data/Application/580A9879-23CD-413D-A785-DB910673DF74/tmp/some_guid_image_name.jpg

When the app is upgraded, this file no longer seems to exist.

Where should I be saving the image files to in iOS so that they persist across upgrades?

The functionality works perfectly on Android devices.

Upvotes: 1

Views: 134

Answers (1)

Simon Hutton
Simon Hutton

Reputation: 1787

Having received no answers, I delved a bit deeper and discovered that...

...the tmp directory in which the images are being written is for 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 or iCloud.

So in order for the data to persist over app updates, I need to be writing to the Documents directory

Info obtained from here

Upvotes: 1

Related Questions