Persist Local Data

Pick the least powerful storage that satisfies durability, query, target, and privacy requirements.

Workflow

  1. Classify the data: preference, file, record, cache, secret, or sync source.
  2. Choose the target matrix: Android, iOS, desktop, web.
  3. Decide whether export/restore is required before sync.
  4. Write migrations before shipping schema changes.
  5. Test wipe, restore, upgrade, and low-storage behavior.

Starting Choices

DataStart with
Theme, onboarding flag, small primitive settingshared_preferences
User-created exportable documentFile APIs with platform paths
Queryable local recordsSQLite-backed store
Offline-first app stateLocal DB plus mutation queue and backup/export
SecretsPlatform secure storage and explicit recovery model

Do Not Skip

migration test
export file smoke
restore smoke
delete account/data path
backup threat model

Gotcha: shared_preferences is not a database and should not hold critical records. It is for small primitive values.