- Home /
Saved Android app files get automatically recovered from nowhere even after re-installing app.
I only have this issue when I set external storage (which I need for my app as it saved images to gallery). Certain files saved by my game a few months ago will keep coming back even after uninstalling the app and reinstalling it. Upon uninstall you can see that they all get deleted fine in the Android/data/... folder, along with all the app data. But then upon re-install they pop back out of nowhere, as if there was some mechanism that would recover deleted app data from some cache folder that is stored elsewhere, some automatic default mechanism that I don't know of. The recovered app files include specific images, screenshots from the game saved months ago so no way does my code add them back, it has to be sitting somewhere outside of the persistentdata path, a place that Android uses to recover data from on reinstall. It could also be a Unity recovery mechanism.
Answer by krisventure · Apr 15, 2017 at 09:11 PM
Found the cause of the problem (took me a whole day though):
It's due to an auto-backup feature since Android 6.0. All your app data is automatically backed up to your linked Google account. You can find the back up in your Google Drive. By default the backed up data will be restored upon reinstall. I turned off Wifi on my dev phone for a while and only turned it back on recently, that's why I had this weird experience of files haunting me from the past all of a sudden.
Solution:
If it bothers you too during development (as the saved data structure may change across builds), you can just turn it off in Cloud And Accounts / Backup And Restore / Automatic Restore.
You can also disable auto backup for your app entirely by adding android:allowBackup=“false” to your androidmanifest.xml file inside the application statement. Make sure to add this to the manifest file at Asset/Android/Plugins, this is how you tell Unity to merge your modifications with its auto-built manifest. In case you don't have it there yet, copy the one from Temp/StagingArea after a build.
First of all thank you so much for this. Saved me another day of work trying to figure it out. Secondly, you didn't write what should be added to the manifest... And lastly: in my Android device the location of that specific setting is in Settings -> Backup and Reset -> Automatic restore.
Thanks again :)
Thanks, I've edited! I thought I've gone crazy because I was sure I've added that info. Turns out anything you type between angle brackets will get deleted upon saving your Answer on this forum. I just copied the statement from my manifest file that was in between angle brackets so it got deleted. When I need to start debugging Q&A sites to share the results of another debugging, I'm beginning to feel dizzy :)
By the way, I decided to keep the backup function, only disabled it on my dev phone. $$anonymous$$y thinking is that this is an awesome feature after all which allows your users to continue your game/app with their earlier progress/settings even if they uninstall it and reinstall a few months later. You don't need to create personal accounts for everyone and save all that data on a server just for this yet you have the feature of restoring from earlier installs. I think that's cool
Answer by JbStudio425 · Jul 04, 2019 at 04:36 AM
Include This At
Assets/Plugin/Android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<application android:allowBackup="false" tools:replace="android:allowBackup">
</application>
</manifest>
Answer by cyborgjinx · Nov 08, 2019 at 10:05 AM
I tried this but data is still getting recovered.
I tried changing device resolution at runtime for performance but took out the code as it wasn’t needed.
However, the device gets the down scaled resolution every time. If WiFi is off, the resolution is correct but it’s the wrong resolution when WiFi is on