Menu

1 / 3

Backup and restore for an Android launcher with Room: debounced snapshots and an empty-database gate

DEV Community: android·ReClaim·2 days ago
#SGqQHvP1
#devtoandroid#devto#dev#file#backup
Reading 0:00
15s threshold

We're building ReClaim , a minimalist Android launcher that's now on Google Play . A launcher stores a lot of small, personal things: your home screen order, folders, hidden apps, blocks, schedules, timers and tasks. Nobody notices that setup until it's gone.

So we built our own backup and restore. It isn't Android's BackupAgent . It's a plain class, also called BackupManager , that does three things:

It keeps a local snapshot of the whole setup, updated automatically.

It can export that snapshot as a single zip the user moves to another phone.

It can restore from either, all or nothing.

Here's how it works, traps included. Stack: Kotlin, Hilt, Room, DataStore, coroutines, minSdk 26 , targetSdk 36 . Snippets are trimmed from the real code; // ... marks cuts.

1. One JSON file, kept outside databases/

The snapshot is one JSON document that holds every user-data table, the settings, and a flag for the home background image. It lives in filesDir/backups/ , not next to the database.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.