How to Test an Android APK Upgrade With Existing User Data
Build realistic Android upgrade fixtures, install the candidate without clearing data, and verify saved state before and after sync.
Table of Contents9 sections

An APK can install successfully and still lose the things a person opened the app for. A proper Android upgrade test starts with an older app and meaningful local state, replaces it without uninstalling, then checks what the person can actually find and do on the new version.
Quick solution:
Install an old build in a disposable QA environment. Create recognizable data in that build, record a baseline, and update in place with the intended delivery channel. Check local state before reconnecting, then check that updates and sync still work.
Old install → seed known records → record baseline
Upgrade in place → first launch offline → verify existing state
Restart → edit again → reconnect → verify sync once
The fictional examples use a warehouse notes app and synthetic records. Never test upgrade or negative install behavior against someone’s personal app data.
Define what an in-place upgrade has to preserve
Make a short inventory of the state that survives a normal app update. Think beyond database rows: unreadable attachments, reset preferences, broken offline drafts, unusable login state, and missing queue entries can all hurt users even if the database schema is valid. At the same time, some data is deliberately disposable. A thumbnail that can be regenerated is not equivalent to a photo that was never uploaded.
For each category, define a user-visible invariant. An offline note should remain readable. Pending work should still be queued or be reconciled without creating a second operation. A chosen large-text preference should still affect the UI unless the release intentionally changes that behavior. A session might legitimately require a fresh sign-in under a security policy. In that case, the correct expectation is a clear reauthentication path and controlled access to local data, not bypassing sign-in or simply checking that the old token still works.
Tie the scope to the change and to the older builds still in use. Start from the newest shipped build and the oldest supported one. Add another start if it represents a real difference, such as an older storage format or an earlier signing transition. An app version name and a schema version are not interchangeable: several released binaries can share one Room version while differing in how they stored files or preferences.
Build a fixture with recognizable values
Seed the old app through normal user flows where possible. That exercises the actual code that wrote the data and avoids inventing a database shape that never existed. Add one record that is already synchronized, one newly saved offline draft, and one attachment with a synthetic filename and known contents. Pick a nondefault setting and use a timestamp or short label you can find after migration. An empty screen will not reveal losses and two identical rows make duplication hard to detect.
Record a small pre-upgrade baseline: build ID, application ID, version code, device configuration, network state, and the records or settings you intend to check. A few concrete values are enough. For the fictional fixture, record that note N42 has body “Check bay 4”, note N43 is an offline draft, photo QA-example.png opens, and large text is switched on. No real client records or account details need to enter a fixture, test log, or screenshot.
If the app maintains both local and server records, make one change that only exists locally and verify it before replacing the app. This gives you a way to tell “preserved on disk” apart from “restored from the server at startup.” If you can seed through an approved fixture instead, document that difference and verify that the resulting stored state matches what an actual old release would produce. Don’t claim to have tested a realistic upgrade when you only injected data with the newest code.
Verify the two packages can actually replace each other
Android’s app update guide describes how application ID, signing, and version determine whether a package can update the installed app. For an ordinary forward update, use the same application ID, an appropriate compatible signing identity, and a higher version code in the candidate. Android’s versioning guide explains why the displayed version name is not a substitute for the code used for update ordering.
Check the production-equivalent variant before the test. A debug APK with a different application ID can install beside the old build, making the first launch appear empty because it is a different installation. If the ID matches but the signing identity isn’t compatible, the package manager may reject replacement. Neither result is evidence of data loss in an upgrade. Fix the fixture or the candidate selection, then try a real in-place replace. Do not uninstall just to make the install succeed: that destroys the test’s prerequisite.
If the build is distributed by Google Play, consider using the appropriate test track and installer as part of verification. A locally signed file that could never replace the track-installed copy is not an equivalent test of that release. If your distribution uses generated splits or dynamic modules, use the expected delivery path or a supported setup that actually exercises the relevant installation. Keep the build and version identification with your reports so another tester can repeat it.
Replace the older build without wiping it
For a directly delivered, single APK on an authorized QA device, Android’s ADB documentation describes the install replacement option that keeps the existing app data. Use the normal installer that applies to your project, and confirm the device and file first. The following commands illustrate the sequence for a disposable emulator, not a command to run against a personal device.
serial="emulator-5554"
# Start with a prepared QA emulator that does not already have this app.
adb -s "$serial" install old-qa.apk
# Open the old app, create the fixture, and record its state before continuing.
adb -s "$serial" install -r candidate-qa.apk
Don’t clear storage, restore a snapshot from after the upgrade, or accept a convenience script that silently uninstalls on failure. If the second install fails, record the actual error before changing anything. After a successful update, confirm the build ID or effective version code. A tester can accidentally reopen the old copy after a failed update and report that everything survived, when in fact the old binary was never replaced.
Separate upgrade, fresh install, and restore into different cases. A fresh install checks first-run setup. A backup restore checks an installation that receives prior state through its own rules. The in-place case checks the same installed app moving forward with existing local state. A pass in any one does not imply a pass in the others. Restore each run to a fixture from before the candidate, or create a new old-build test environment, so later attempts don’t start from data that has already migrated.
Observe the first launch before sync can hide a loss
When your product supports offline use, take the device offline before launching the candidate. Check that the offline record, attachment, and settings are present. If the product requires online authentication at launch, don’t disable the policy to make the test pass. Use a documented pre-sync inspection or a controlled test service that can distinguish local persistence from server rehydration. In the report, state which path you actually exercised.
Continue beyond looking at the list. Open the old record, read its content, make a new edit, and confirm that the change survives a restart. Check a detail view or an exported representation when those use different code paths. Then reconnect and confirm that the pending operation is delivered correctly and that the result is not duplicated. An app can show the original notes but still be unable to write new values or drain a queue after upgrade.
An offline check does not replace a sync check. The two establish different facts. If N43 is missing offline but reappears online, you have not verified local continuity. If it stays visible offline but sends twice after reconnecting, the database may be intact while the operation state is wrong. Use observations at each boundary to narrow down where the bug lives rather than grouping every failure under “migration.”
Keep Room tests and whole-app tests separate
A Room migration test can check the expected schema and let you assert known fixture values with fewer moving parts. The guide to Room migrations across skipped app versions explains how to select old starting schemas. Those checks are valuable even if you already have a UI upgrade test. They can isolate missing paths before packaging or on-device test time is involved.
The whole-app upgrade test checks more than the database. It can reveal that a different application component builds the database without the expected migrations, that an attachment path doesn’t resolve, or that session handling prevents a user getting to the migrated screen. A unit test or migration helper doesn’t establish that release signing, delivery, or startup flows are correct. Conversely, a handful of on-device smoke tests doesn’t exercise each version transition precisely. Use both layers for the risks that matter.
If a release touches shared preferences or local file formats rather than Room, build an equivalent fixture and explicit assertions for those assets. Treat a versioned app-state change as a compatibility decision. For cloud data, verify the app neither deletes nor silently overwrites the authoritative record during reconciliation. Keep the case focused on what changes and what could be costly to lose; no need to inspect every cache directory just because it exists.
Work through a failed first launch
Suppose the new APK installs cleanly and opens. N42 is visible, but N43 is missing offline. Large text still works, and the attachment opens. The fixture and confirmed build ID narrow down the problem: package replacement succeeded, and at least some persisted categories survived. Ask whether the offline operation is absent, still queued but filtered from view, or present but unreadable. Don’t clear app storage to see if the issue disappears; that would remove the defect conditions.
Reconnect only after preserving the offline evidence. If N43 appears later when the service responds, distinguish a server copy from a recreated local record and check whether the original edit is present. If the pending operation was resubmitted, verify its identity and whether the receiving system accepted it once. In the report, describe what the tester actually observed: “N43 absent on the first offline launch after upgrading, present after reconnect; original pending edit not verified.” That is more useful than writing “data loss” without qualification.
Run a fresh-install control separately if startup is also bad on a clean device. That may reveal an unrelated initialization bug, though it doesn’t cancel the upgrade failure. If release has already begun, share which installed versions and record categories might be affected, and let the release owner act on the evidence. Don’t recommend a downgrade as a generic fix: a newer app may have written state that the old version cannot read.
Decide a pass from the user-facing invariants
For routine releases, a compact matrix can cover the meaningful starting points and keep results comparable. Expand it when storage formats, installation channels, supported device configurations, or preserved state change. Label these expectations before running the test so a partial pass does not quietly become a complete pass.
| Case | What to prove |
|---|---|
| Latest old release, in-place | Known data and settings are usable on the new version |
| Oldest supported release, in-place | Skipped versions do not break preservation or startup |
| Offline draft before update | Preserved locally, then reconciled correctly on reconnect |
| Existing file or attachment | Content still opens, not just a filename in the list |
| Fresh install control | First-run behavior succeeds without relying on old state |
| Installer rejects candidate | Old app remains; investigate package or delivery mismatch |
Keep a short handoff with the source and destination builds, fixture, method, results, and any uncovered risk. If backup restore, account migration, or update interruption is important to your users, make it a separate named case instead of implying it passed. A defensible release note says “upgraded without uninstalling and verified these user-visible values.” “Installed successfully” establishes much less.
You Might Also Like
View all articles
How to Trace an Android QA APK Back to Its Git Commit
Identify the exact Android APK on an authorized QA device, match it to CI, and record the Git revision without confusing version labels, signers, or splits.

How to Build a Secure In-App APK Update Flow on Android: Off-Play Architecture
Design a reliable off-Play Android update flow with signing continuity, version checks, package verification, user consent, and observable install states.

How to Choose a Minimum Test Suite for an Android Hotfix
Choose a small Android hotfix test suite around the incident, adjacent risk, and the release artifact without skipping mandatory checks.