Hi dev, are you also experiencing the same thing? Okay good, that means you are also in a transition period from ancient to modern
Okay, no need to beat around the bush, so the consequence of using SDK version 23 - and above is that you have to be able to adapt to several rules of the game, of course the new version brings a new culture (future), one of which is if we activate autobackup.
allowBackup true makes shared preferences persist when your app is uninstalled
android:allowBackup="true"
then we also need to provide an xml file to accommodate the data that will be stored.
The mechanism is that the android system will upload user data to their Google Drive account, where it is specifically protected by the user's Google account credentials. By default the max size of data backed up is 25MB per user, but in the process you can customize it or disable it.
How to do it? you have 2 options disable or create xml file.
1. Disable allowBackup
android:allowBackup="false"
2. Create an Act in the form of an XML File
Hahaha sorry I mentioned UU because the file is dedicated to defining the rules of the backup process, so that the Android system doesn't carelessly back up unimportant or sensitive items.
Okay, let's go straight to the project, right click the res folder -> new -> android resource directory -> change the resource type to "xml" -> OK.
Then what should be filled in? I'll give you an example of a standard format.
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<full-backup-content xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This file is referenced from android:fullBackupContent in AndroidManifest.xml, and controls
exclusions/inclusions for the default backup policy. -->
<!-- Shared preferences files can be excluded using the "sharedpref" domain. -->
<!-- Be sure to exclude any device-specific identifiers, such as the GCM registration key. -->
<!-- You may also wish to exclude directories that contain device-specific session tokens or
sensitive user credentials. -->
<exclude domain="sharedpref" path="gcm"/>
<exclude domain="sharedpref" path="SESSION_AUTH"/>
<!-- Databases can be excluded using the "database" domain. -->
<exclude domain="database" path="user.db"/>
<!-- Additional domains include "file", "external", "root", and "path". See
http://developer.android.com/preview/backup/index.html for more details.
Additionally, content in the cache directory, external storage, and the no_backup directory
(see android.content.Context#getNoBackupFilesDir()) are excluded by default. If you need
to backup data in one of these locations, use the <include> directive. -->
</full-backup-content>
<exclude> is for making exceptions, while <include> is for including certain things. Incidentally, in the case above, I made a statement to backup all files in the sharedpref folder, except for files named "gcm" & "SESSION_AUTH.
If so, then define it in your manifest in the <application> tag.
android:fullBackupContent="@xml/my_rule_backup"
Okay, done, that's all, why bother. Good job!