It's because Android 6 has automatic backup. You need to tune android:allowBackup
and android:fullBackupContent
in your manifest <application>
tag if you don't want your data backed up or if you want to include or exclude some resources. It's not a bug.
More about AutoBackup on Android here.
greywolf82's answer is correct but I want to add some info to this.
When developing my Android app (using Xamarin), I noticed that whenever I'd re-launch the app from Visual Studio, my data would revert back to data from a few months ago. It didn't matter if I simply stopped and re-ran it from VS, or if I completely uninstalled the app and reinstalled it.
It's also worth noting that we never explicitly told the app to store a backup.
The backup also seemed to overwrite newer data when launching from Visual Studio, and we have reports of users using the release build of our app and also getting newer data overwritten by the backups.
Since I don't know exactly when backups and restores occur this feature seems to cause only problems.
We've modified our AndroidManifest by adding the following two lines:
android:allowBackup="false"
android:fullBackupOnly="false"
After adding them, our AndroidManifest contained the following xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.XXXXXXX" android:versionName="8.0.0" android:installLocation="auto" android:versionCode="439">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="24" />
<application
android:label="@string/appName"
android:icon="@drawable/icon_small"
android:installLocation="internalOnly"
android:largeHeap="true"
android:allowBackup="false"
android:fullBackupOnly="false"
/>
...
</manifest>
Once we explicitly set the value to false, all seems to work. I'd expect this to be an opt-in feature but...seems like it might be on by default for apps which don't specify the value either way.
You should check your device's Backup and Reset settings, and turn off Automatic restore (when reinstalling an application, backed up settings and data will be restored.)
Turning off auto-backup is different from the auto-restore. If you think it will be helpful to turn on auto-backup for your application do so. But if you think this will make end users who are not aware that the auto-restore feature of their device is turned on, feel free to turn it off.
In my case, I turned off the allowBackup feature, but since I already had a backup of the previous version on the Cloud, it still kept on restoring.
See image as reference for a Samsung device on Android 6.0. Other devices and versions may have a different screen. See image below.
Automatic Restore Setting under Backup and Reset
I recently needed to take advantage of these features, I was able to uncover documentation and upon extensive testing this is what I have been able to deduce:
Android:allowbackup - will backup local app data on the device it is located on.
Android:fullBackupContent - is used in conjunction with Google's backup restore api and CAN be controlled via an xml file to specify what exactly to backup, as well as a BackupManager class you may implement for further control over the process.
However the documentation states, and I have confirmed with testing, that a restore will only occur either when the device is restored and the restore app data process is triggered. OR it will also restore when the app is sideloaded through adb, which is what we do when we run the app for testing or debug on our devices through Android Studio. Note that if you set android:allowbackup but do not configure android:fullBackupContent with a Google api code then the apps data only gets stored locally, whereas if you configured it properly then if your app was backed up and you get a new device the apps data was stored on the cloud so it can be restored on a new device.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With