# Local Storage: Key-value, SQLite & Files

> Choose the right on-device storage for settings, structured data, files and secrets, and handle schema migrations. Free notes, key concepts, resources and a...

Canonical: https://www.internhack.in/roadmaps/tracks/mobile/local-storage
Last updated: 2026-11-28

Choose the right on-device storage for settings, structured data, files and secrets, and handle schema migrations.

Intermediate · about 7 hours · difficulty 3/5

Learn first: [Networking Clients & Server-state Caching](https://www.internhack.in/roadmaps/tracks/mobile/networking-clients)

Apps store data locally for speed, offline use and continuity. Picking the wrong store is a common source of bugs and security issues.

### Options

- **Key-value stores** for small settings and flags: AsyncStorage or MMKV (React Native), shared_preferences (Flutter), DataStore (Android), `UserDefaults`/`@AppStorage` (iOS). Not for large or relational data.
- **SQLite** for structured, queryable data: expo-sqlite, Drizzle or WatermelonDB (React Native), drift or sqflite (Flutter), Room (Android), SwiftData/Core Data (iOS, built on SQLite).
- **File system** for images, downloads and exports: expo-file-system, path_provider, app-specific directories.
- **Secure storage** for tokens and secrets: Keychain on iOS and Keystore-backed storage on Android, via expo-secure-store or flutter_secure_storage. Never put tokens in plain key-value storage.

### Migrations

When your schema changes in version 2, users still have version 1 data. Write versioned migrations and test upgrading from an old build.

### Pitfalls

- Storing large JSON blobs in AsyncStorage and parsing them on startup slows launch.
- Assuming storage survives forever; the OS or user can clear it. The server should remain the source of truth for important data.

**Good enough to move on:** your app keeps settings in key-value storage, records in SQLite with one migration, and the auth token in secure storage.

## Key concepts

- **Key-value storage**
- **MMKV**: Fast synchronous KV for React Native
- **SQLite and ORMs**
- **Schema migrations**
- **File system storage**
- **Secure storage for secrets**
- **Choosing the right store**

## Mini project

Build an expense tracker storing entries in SQLite with a category filter, preferences in key-value storage, and add a migration that introduces a notes column.

## Check yourself

Where should an access token live on the device, and why not in AsyncStorage or SharedPreferences?

## Free resources

- [Expo SQLite](https://docs.expo.dev/versions/latest/sdk/sqlite/) (Expo)
- [Expo SecureStore](https://docs.expo.dev/versions/latest/sdk/securestore/) (Expo)
- [Android: Data and file storage overview](https://developer.android.com/training/data-storage) (Android Developers)
- [SQLite documentation](https://www.sqlite.org/docs.html) (SQLite)

Previous: [GraphQL Clients](https://www.internhack.in/roadmaps/tracks/mobile/graphql) · Next: [Offline-first & Data Synchronisation](https://www.internhack.in/roadmaps/tracks/mobile/offline-first)

## More in Data: Networking, Storage & Offline-first

- [HTTP & REST APIs for App Developers](https://www.internhack.in/roadmaps/tracks/mobile/http)
- [Networking Clients & Server-state Caching](https://www.internhack.in/roadmaps/tracks/mobile/networking-clients)
- [GraphQL Clients](https://www.internhack.in/roadmaps/tracks/mobile/graphql)
- [Local Storage: Key-value, SQLite & Files](https://www.internhack.in/roadmaps/tracks/mobile/local-storage)
- [Offline-first & Data Synchronisation](https://www.internhack.in/roadmaps/tracks/mobile/offline-first)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Mobile App Developer Roadmap](https://www.internhack.in/roadmaps/tracks/mobile)
