Android M weird shared preferences issue

前端 未结 3 1704
遥遥无期
遥遥无期 2020-11-29 05:20

On my Nexus 5 running Android M Developer Preview 2, when uninstalling/reinstalling an app, the device is retrieving shared preferences I stored long ago, for instance a boo

相关标签:
3条回答
  • 2020-11-29 05:25

    That is because Android M will feature Automatic Backups (old link).

    Extract:

    The automatic backup feature preserves the data your app creates on a user device by uploading it to the user’s Google Drive account and encrypting it. There is no charge to you or the user for data storage and the saved data does not count towards the user's personal Drive quota. During the M Preview period, users can store up to 25MB per Android app.

    0 讨论(0)
  • 2020-11-29 05:32

    Open settings -> Backup & reset -> automatic restore -> off if is on then app cache and database will be restore.

    0 讨论(0)
  • 2020-11-29 05:42

    Even already answered this question above, not mentioned the actual solution to avoid the auto backup even after uninstalling the app.

    As per official, doc says to avoid auto backup need to do <application android:allowBackup="false"> in the Manifest file under application tag.:

    Enabling and disabling backup Apps that target Android 6.0 (API level 23) or higher automatically participate in Auto Backup because of the android:allowBackup attribute defaults to true. To avoid any confusion, you should explicitly set the attribute in your manifest as follows:

    <manifest ... >
        ...
        <application android:allowBackup="true" ... >
            ...
        </application>
    </manifest>
    

    You might want to disable backups by setting this to false if your app can recreate its state through some other mechanism or when your app deals with sensitive information that should not be backed up

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