Nick Nick - 1 year ago 69
Android Question

Android - Application database is being restored after complete wipe of phone

I am creating an Android app and the database is being persisted after uninstalls. When I uninstall the app, the application dir is destroyed (/data/user/0/<name>), which is good. But when I install the app again, the database is restored with the old data.

With the application uninstalled, I'll hit the debug button on Android Studio which installs the APK. I put a breakpoint on the very first line of my application class (the one that extends Application), and while that breakpoint is hit, I navigated to the /data/user/0/<app name>/databases folder and did an ls and the DB is there. It never even hit my database class yet to init it. I'm stumped and can't figure out why it's doing this.

Here's how I've tried to debug it thus far:

  1. Downloaded the APK from the phone after it's installed, opened it up and searched for the database in there.

  2. Renamed the database in the code, which creates a new DB file with the right name, but the old DB is still created. The DB with the new name doesn't seem to appear to persist after uninstalls.

  3. I've searched both my both my computer's and phone's root dir for the databases file name, which doesn't appear to show the database file.

  4. I completely wiped the phone by re-installing the OS, rooting the device, and putting TWRP on there along with a factory reset.

  5. Disabled instant run.

The phone I'm on is a Nexus 6p running Android 7.0.

Android Studio information:

Android Studio 2.2.1

Build #AI-145.3330264, built on October 6, 2016

JRE: 1.8.0_112-release-b05 x86_64

JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

tl;dr, my app database keeps coming back after uninstalls/device wipes.

Answer Source

Have you tried adding this to your android manifest?


remember it should be inside the application tag.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download