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:
- Ran
./gradlew clean
in the android directory - Rebuilt the android directory from scratch
- Removed all cache files and directories from the project (.gradle, .expo, etc)
- Used
AsyncStorage.clear()
andAsyncStorage.removeItem()
- Used storage analyzers to search for data (didn’t find anything)
- Manually removed storage and cache through Android Settings -> Apps & Notifications
- Uninstalled the app from the device
- Deleted Expo Go app and removed it’s storage and cache
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()
or AsyncStorage.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
- Remove storage items with
AsyncStorage.clear()
orAsyncStorage.removeItem()
- Delete app storage and cache in Android
Settings -> Apps & Notifications
- Uninstall the app from the device
- Stop
react-native
- Run
./gradlew clean
in the android directory - Start
react-native
with--reset-cache
flag - Run
react-native run-android
to install the app
Environment
- Platforms tested:
- Android
- iOS
- macOS
- Windows
- AsyncStorage version: 1.14.1
- Expo version: SDK40 (bare workflow)
- Environment:
System:
OS: Linux 5.8 Pop!_OS 20.10
CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Memory: 12.40 GB / 31.08 GB
Shell: 5.8 – /usr/bin/zsh
Binaries:
Node: 14.15.4 – ~/.nvm/versions/node/v14.15.4/bin/node
Yarn: 1.22.10 – ~/.nvm/versions/node/v14.15.4/bin/yarn
npm: 6.14.11 – ~/.nvm/versions/node/v14.15.4/bin/npm
Watchman: Not Found (Watchman is global)
SDKs:
Android SDK: Not Found (it sure does, it’s in my home directory)
IDEs:
Android Studio: Not Found (not using android studio)
Languages:
Java: 11.0.10 – /usr/bin/javac
Python: 2.7.18 – /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: ~0.63.4 => 0.63.4
npmGlobalPackages:
react-native: Not Found (uses npx version)
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:
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.