Closed mdbiscan closed 3 years ago
Hey @mdbiscan , thanks for filling in all the details!
One thing that comes to my mind is Auto back up of user data, that's enabled by default for devices targeting Android API 23+. You mention that you search through old issue, so I guess you tried to disable it? (dunno if you have access to manifest file in Expo app)
Is your project ejected? Are you able to reproduce this on non-expo app (react-native init
)? Could it be that some of the other dependencies doing the backup or maybe Expo is doing backups? cc @brentvatne
@Krizzu thanks for the reply!
The project is ejected. I hadn't thought of Auto Backup. I read about automatic exclusion to iCloud for iOS devices, but didn't see one for Android. I will look into it.
Looks like this setting in the AndroidManifest.xml
file is on by default: android:allowBackup="true"
For future reference, this is the generated XML line from Expo:
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme">
Setting this to false solves the issue. I'm not sure this is a good idea or not, as we also use keychain storage. I'm not sure if this backup feature also saves encrypted storage to the cloud.
Either way, thanks for pointing me in the right direction. I figured it might be some obtuse setting.
ios has the same problem, how to solve in ios?
Did you try to disable iCloud backup? documentation
Hey @mdbiscan and @krizzu, does this apply to the Documents Directory pointed to by FileSystem.documentsDirectory? On iOS and Android?
I think I'm having some bugs due to this its just a hunch. I'm going to try to set that allowBackup to false in xml for Android, how could I do this for iOS?
Not using AsyncStorage but Expo filesystem - https://docs.expo.dev/versions/latest/sdk/filesystem/
https://github.com/react-native-async-storage/async-storage/issues/569#issuecomment-808319211
i tried this in my current my project, and a repro project
both have android:allowBackup="true"
but only in my current project that the async storage data persist upon app uninstall and reinstall
in my repro project which is new expo project, data will be removed after i reinstall the app.
still not sure how to fix this
@mdbiscan, you saved my day
yup, that's likely the issue! Since android:allowBackup="true"
is enabled, Android is backing up the app's data to the cloud, and when the user reinstalls the app, the old data is restored automatically.
If some users already have old data backed up to the cloud, they will continue to restore that data even after you disable backup for new users. To fully resolve the issue, users need to manually clear their app backup data.
Steps for users to clear backup data:
Go to Settings > Google > Backup > App data. Find your app in the list and select it. Tap Delete backup.
Current behavior
I'm using AsyncStorage for persisted storage. I noticed (while debugging an unrelated issue with Expo SecureStore) that the key/value pairs are persisting after I've uninstalled the app from my device.
I've tried the following:
./gradlew clean
in the android directoryAsyncStorage.clear()
andAsyncStorage.removeItem()
It is my understanding that uninstalling the app should also remove persisted storage. However, this issue goes beyond this assumption if I am incorrect.
The items always show up after I uninstall and reinstall the app. Reloading the app does not have this same issue. I read through some old/closed issues here that showed others having this problem, with solutions that have not worked for me. Even after using
AsyncStorage.clear()
orAsyncStorage.removeItem()
, the items will appear on every new install, but only after the app has been uninstalled from the device.Expected behavior
After new installation or removing them, the storage items should no longer exist on the device.
Repro steps
AsyncStorage.clear()
orAsyncStorage.removeItem()
Settings -> Apps & Notifications
react-native
./gradlew clean
in the android directoryreact-native
with--reset-cache
flagreact-native run-android
to install the appEnvironment