Common Orientation Change Bugs in Database Client Apps: Causes and Fixes

Screen rotation triggers Android’s activity lifecycle: onPause → onStop → onDestroy → onCreate → onStart → onResume.

January 22, 2026 · 4 min read · Common Issues

What causes orientation change bugs in database client apps (technical root causes)

Screen rotation triggers Android’s activity lifecycle: onPause → onStop → onDestroy → onCreate → onStart → onResume.

In database client apps the following interactions often break:

Root causeWhy it matters
Database connection not persistedThe SQLiteOpenHelper or network socket is created in onCreate. When the system recreates the activity, the helper is re‑instantiated, closing the existing connection and opening a new one. If the app does not re‑establish the link, queries return empty results or throw SQLiteException.
ViewModel / LiveData not usedUI state lives in fragments or activities. Without a ViewModel, user input (e.g., a filter) is lost because savedInstanceState does not contain complex objects.
Cursor / ResultSet not resetA CursorLoader or LiveData> may still hold a reference to the old cursor after rotation. The UI continues to iterate over stale data, causing duplicate rows or missed updates.
Transaction state leakageAn ongoing write transaction (INSERT/UPDATE) may be committed on the first instance and left dangling on the second. The second instance may attempt to commit again, leading to constraint violations.
Async tasks not cancelledAsyncTask, ExecutorService, or Retrofit calls that are not cancelled in onPause will continue to post results to UI threads after the activity is destroyed, resulting in NullPointerException or ANR.
Fragment back stack mishandlingWhen a fragment is replaced during rotation, the back stack may be rebuilt incorrectly, causing navigation to skip screens or show blank panels.
Resources not cleaned upUnreleased Bitmap objects, file handles, or network streams remain in memory, causing gradual leaks that surface after multiple rotations.

These root causes are amplified in database client apps because the UI is tightly coupled to data retrieval and persistence logic.

Real-world impact (user complaints, store ratings, revenue loss)

5‑7 specific examples of how orientation change bugs manifests in database client apps

  1. Lost connection after rotation – The app displays a “Connected” icon, but after rotating the device the status reverts to “Disconnected” and all queries return empty sets.
  2. Duplicate rows in result list – A list of records shows each entry twice after rotation because the adapter’s cursor is not cleared before binding new data.
  3. Undo/redo actions disappear – A user edits a record and clicks “Undo”. Rotating the screen discards the undo stack, making the action irreversible.
  4. Uncommitted transaction persists – While typing a new invoice, the user rotates the screen; the draft remains in the UI but the transaction is rolled back on the new activity instance.
  5. Dead “Save” button – The button becomes grayed‑out after rotation because the UI check (if (isDirty)) still references a stale isDirty flag.
  6. Accessibility focus jump – VoiceOver starts on the first item after rotation instead of the previously focused item, breaking the user’s navigation flow.
  7. Memory leak causing gradual slowdown – After several rotations the app’s memory usage climbs ~30 MB, eventually leading to ANR during normal operation.

How to detect orientation change bugs (tools, techniques, what to look for)

How to fix each example (code‑level guidance where applicable)

1. Lost connection after rotation

2. Duplicate rows in result list

3. Undo/redo actions disappear

4. Uncommitted transaction persists

5. Dead “Save” button

*

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free