Skip to main content

Summary

This feature allows users to take full ownership of their data by creating portable backups. Users can export their entire usage history, settings, and sessions into a single compressed file. Conversely, they can restore this data later, which is essential for migrating to a new device or recovering from data loss. The system includes safeguards to validate files before importing and provides real-time progress estimates during long operations.

How It Works

Exporting Data

The export process involves calculating the data size, asking the user for a save location, and then streaming the database content into a compressed file.
1

Preflight Estimation

When the user opens the export screen, the app immediately runs a “preflight” check. It counts all the rows in the database to estimate the final file size and how long the backup will take. This helps the user decide if they have enough time and storage space.
2

File Creation

The user clicks “Create Backup,” launching the system’s file picker. The user chooses where to save the file (e.g., Google Drive or local storage). The app creates a compressed file (GZIP) to minimize storage usage.
3

Streaming Data

The app reads data from the local database table by table. It converts this data into a text format (JSON) and compresses it on the fly. This happens in chunks so the app doesn’t run out of memory, even with very large databases.
4

Progress Tracking

As data is written, the app calculates the percentage complete based on the total rows counted in step 1. It also calculates the “Time Remaining” (ETA) by measuring how fast rows are being processed and comparing it to the remaining work.

Importing Data

The import process is designed to be safe. It verifies the file contents before making any changes to the local database.
1

File Selection & Validation

The user selects a backup file. Before importing, the app reads just the “Header” of the file. This header contains metadata like the backup version, the date it was created, and the range of dates the data covers.
2

User Confirmation

The app displays the information found in the header (e.g., “Backup from Jan 1 to Dec 31”). The user must review this and confirm they want to proceed, often acknowledging that this might overwrite existing data.
3

Restoration

Once confirmed, the app reads the compressed file. It clears the relevant tables in the local database and inserts the historical data. Like the export process, this shows a progress bar and an estimated time of completion.

Data Stored

The backup file contains a comprehensive snapshot of the user’s activity. The following categories of data are included:
Data CategoryDescription
Scroll SessionsDetailed records of continuous usage sessions (start time, duration).
App EventsRaw usage events generated by the operating system.
App MetadataNames, icons, and categories of installed apps.
Unlock SessionsRecords of when the device was unlocked and locked.
Daily SummariesAggregated stats for device usage per day.
App UsageAggregated stats for specific app usage per day.
InsightsCalculated behavioral insights and trends.
NotificationsHistory of notification counts and interactions.
Limits & GroupsUser-defined usage limits and app groupings.
Nudge StatsStatistics on how often intervention “nudges” were triggered.

Key Components

Export/Import Sheets

The user interface components that guide the user through the process, displaying progress bars, time estimates, and success/failure messages.

ViewModels

ExportViewModel and ImportViewModel manage the state of the operation. They calculate the percentage complete, handle cancellations, and format the “Time Remaining” for the UI.

BackupRepository

The heavy lifter that actually talks to the database and the file system. It handles the complex logic of converting database rows to JSON (and back) and managing file compression.

Preflight System

A logic component that quickly scans the database before an export begins to provide accurate size and time estimates based on previous performance metrics.
Last modified on January 25, 2026