SQLite Database Not Deleted Upon App Uninstall

Bug Report: SQLite Data Persistence on App Uninstall

Bug Description:

The SQLite component does not appear to remove the entire database when the application is uninstalled from an Android device.

Steps I Proceed:

  1. I create a simple math app in Kodular that uses the SQLite component to save some data as history.

  2. I install the app on an Android device Version 12, 13 and 14.

  3. I add some data to the SQLite database within the app.

  4. I close the app and then uninstall it from the device.

  5. Reinstall the app on the same device.

  6. I observe the result: The data that was previously saved to the database is still present. This indicates that the database file was not deleted upon uninstallation.

Expected Behavior:

When an app is uninstalled, all of its private data, including the SQLite database file, should be completely removed from the device. The app should start with a fresh, empty database upon re-installation.

Actual Behavior:

The SQLite database file remains on the device after the app is uninstalled. When the app is reinstalled, the old data is still accessible.

Device Information:

  • Android Version: (Android 12, 13, 14)
  • Device Model: (Samsung Galaxy A04, A21)

My additional concern:

  • This issue can lead to unexpected behavior and potential privacy concerns for users who expect their data to be fully deleted when they uninstall an app.

Hi Solomon,

Very strange, the database file is created in ASD and, as you wrote, it should be deleted during uninstallation. :face_with_monocle:.

The Android Auto Backup might prevent this
See the answer from Gemini below

Taifun


Uninstalling an app should delete its SQLite database and all other data stored in the app’s private directory. However, there are several reasons why this may not happen, causing data to persist after a reinstallation.

Common Reasons for Data Persistence

  • Android’s Auto Backup: Newer Android versions have an automatic backup feature that can back up app data, including SQLite databases, to the user’s Google Drive. When you reinstall the app, Android can automatically restore this data, making it appear as if the database was never deleted. Developers can disable this feature in the app’s manifest file by setting android:allowBackup to false.
  • Saving to External Storage: If a developer has explicitly configured the app to save the SQLite database file to external storage (like the device’s public storage or an SD card) instead of the app’s private directory, the file will not be deleted upon uninstallation. This is because the app’s private directory is the only one that gets wiped during the uninstall process.
  • Device-Specific Behavior: Some phone manufacturers may have custom versions of Android that handle data differently. On certain devices, the uninstall process may not completely clear all data, leading to lingering files.
  • Debugging and Development: During development, if you’re using an IDE like Android Studio, data can sometimes persist even after an uninstall due to how the development environment handles app data on emulators or connected devices. You can often manually clear the app’s data through the device settings (Settings → Apps → [Your App] → Storage → Clear Data) to ensure a clean slate.
    How to Ensure a Full Deletion

For a user, the most reliable way to ensure the app’s data, including the SQLite database, is completely removed before reinstallation is to clear the app’s data from the phone’s settings before uninstalling it.

  • Go to Settings on your device.
  • Navigate to Apps (or “Application Manager”).
  • Find and tap on the app in question.
  • Select Storage.
  • Tap on “Clear data” (and “Clear cache” as well).
  • Once the data is cleared, you can then safely uninstall the app. When you reinstall it, the database will be fresh and empty.
2 Likes

Yeah, unfortunate that is not happened on my three phones(version 12, 13, 14) also model of A05, A21

OK Nice, those all make sense. so did you think that cause rejection during play store evaluation.

No…
Taifun

1 Like

Just to better understand, how do you check that the database is still present even after uninstallation?

i made math equation solver app and i use sqlite component as history saver, after i solve some equation like this


and uninstall the app, then install again, Their i got all those history already saved in my sqlite

Let’s do a test,
uninstall the app and reinstall it, open it, and before creating the database check in
storage/emulated/0/Android/data/your.package.name/files/databases
to see if there’s any file present.