An Android app remembers its data after uninstall and reinstall

后端 未结 8 2179
半阙折子戏
半阙折子戏 2020-11-28 17:58

While developing an Android app targeting all versions above 4.1, I observed that uninstalling my app and installing it again does not clear its data.

The app is d

相关标签:
8条回答
  • 2020-11-28 18:47

    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 as shown in 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.

    0 讨论(0)
  • 2020-11-28 18:47

    Adding android:allowBackup="false" under application tag in Manifest file solved my issue.

    Here goes the android documentation for Back up user data with Auto Backup

    0 讨论(0)
提交回复
热议问题