android:allowBackup attribute trip pit

Recently, when I was doing overseas Android business, I encountered a very metaphysical bug, that is, when I uninstalled the application, when I reinstalled the application again, there was always a token file in it, and I would log in with the token (invalid token login failed ), even if your token overwrites the original token, even if you uninstall the APP without this file, when you reinstall it, there will still be this file, and there is always the same encrypted string (token) in this file, and I didn't do anything when the APP was initialized, which is really a metaphysical problem.

When I encounter this kind of problem, I also have a headache. I can only analyze the startup process of the application step by step. I found that there is no creation of this file or read and write operations to this file. I have searched online for a long time and there is no corresponding answer. There is really no way, I will check the configuration step by step, starting from the AndroidManifestbeginning. Suddenly found a property android:allowBackup="true". The first thing I thought of was to remove this attribute, and then uninstall and install the app again. I found that it was still useless. As soon as the app was opened, the file was automatically created. The key is that the content in it is exactly the same as it was before the uninstall several times. I was confused. Could it be that a special mobile phone can automatically create files, so I googled this property configuration: Google official documentation.pngat first glance, it is a simple backup, but look down carefully: Google official documentation.pngI wipe, and Google Cloud Backup , and then I checked the settings in my phone, and sure enough, Google Cloud Backup was turned on. After I turned it off, I uninstalled and reinstalled, and found that the previous token file would no longer exist. It was finally done, but I changed my mind. After thinking about it, it is impossible for foreign users to actively turn off Google Cloud Backup, so I set the android:allowBackupattribute to false, and then repeated the previous operation and found that there was no problem, so I continued to read the official Google documentation: Google official documentation.pngit can be seen that, The android:allowBackupdefault attribute is true, even if you remove this tag, the above problems will still occur, so generally in applications, especially foreign applications, if you really don't need backup data, it is best to set it android:allowBackup="false"to avoid inexplicable bug issues.

Reference link: Back up user data with automatic backup function

おすすめ

転載: juejin.im/post/7078133412388667428
おすすめ