Leos Literak Leos Literak - 4 years ago 82
Android Question

Zombie data in Android application

I face very weird situation on certain device (Nexus 5x with Android 7): when I clean its data and uninstall it, then install it with Studio, the app is not unitialized but it uses data from 24th january! I tried the same procedure with a tablet and the app has no data.

I have repeated this procedure many times, I cleaned my project, rebuilt it multiple times and it always starts with 24th january data (both database and shared prefs).

I even tried adb shell and run as to clean up data:

bullhead:/data/data/lelisoft.com.lelimath.debug $ ls -l databases/
total 232
-rw-rw---- 1 u0_a259 u0_a259 98304 2017-02-05 11:03 lelimath.sqlite
-rw------- 1 u0_a259 u0_a259 16928 2017-02-05 11:03 lelimath.sqlite-journal

I deleted them and the app seemed empty - until I deleted it and installed again - 24th january was back.

This is a log how it starts:

$ adb shell am start -n "lelisoft.com.lelimath.debug/lelisoft.com.lelimath.activities.DashboardActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: lelisoft.com.lelimath.debug | lelisoft.com.lelimath.debug.test
I/InstantRun: Instant Run Runtime started. Android package is lelisoft.com.lelimath.debug, real application class is lelisoft.com.lelimath.helpers.LeliMathApp.
D/l.c.l.h.LeliMathApp: onCreate()
D/l.c.l.h.BalanceHelper: Current points balance: 234

This is a location of a database, got from a debugger:



android {
signingConfigs {
compileSdkVersion 24
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "lelisoft.com.lelimath"
resValue 'string', 'app_name', 'LeliMath'
minSdkVersion 16
targetSdkVersion 24
versionCode 300
versionName '3.0.0'
resValue "string", "app_build_number", getDate();
resValue "string", "app_version", versionName;
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

debug {
applicationIdSuffix ".debug"
resValue 'string', 'app_name', 'LeliMath DEV'

Manifest portion:


I do not want o factory reset my phone to get rid off this data. I do not think that this data is in my build. I have not added them and the app in the tablet was empty when installed.

Answer Source

Since Android 6.0 (v 23) onward, Android introduced a new feature called Auto-backup for apps . What this does is, it performs a backup of certain files of an application to a user's Google drive. The list of files it updates include:

  • Shared preferences files
  • Files in the directory returned by getFilesDir()
  • Files in the directory returned by getDatabasePath(String)
  • Files in directories created with getDir(String, int)
  • Files on external storage in the directory returned by getExternalFilesDir(String)

Now this line in the manifest.xml is responsible for it :


If you prefer to disable the backup, should you choose to set the value to false.

Furthermore, the data backed up is in a 24 hour interval and Android uses the JobScheduler API for this purpose, so which means a user has no control over the process of data being transferred.

Also, the space for auto-backups is limited to 25MB , and which is not counted against the user's space quota.

Also, you can set to <include> and <exclude> certain type of data being uploaded, for instance you may not need to save a user confidential data, so it is flexible for that as well, more info on that is available at : Android Auto Backup for Apps (100 Days of Google Dev)

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