question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storage items persist after uninstall on Android device

See original GitHub issue

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() and AsyncStorage.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

  1. Remove storage items with AsyncStorage.clear() or AsyncStorage.removeItem()
  2. Delete app storage and cache in Android Settings -> Apps & Notifications
  3. Uninstall the app from the device
  4. Stop react-native
  5. Run ./gradlew clean in the android directory
  6. Start react-native with --reset-cache flag
  7. 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® Core™ 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)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
mdbiscancommented, Mar 26, 2021

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.

0reactions
Noitidartcommented, Aug 30, 2022

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/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Retain app data after uninstall - Umang Chamaria
Generally, as soon as the user uninstalls an application, application data is removed from the Android operating system. This data includes the app...
Read more >
Android Persist Data After Uninstall - Stack Overflow
"By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user)....
Read more >
Where do Android apps store data that survives uninstall?
Apps are supposed to store their data and related files either in /sdcard/Android/data/com.app.id or /data/data/com.app.id ; however, ...
Read more >
Delete your activity - Android - Google Account Help
On your Android phone or tablet, go to myactivity.google.com. Scroll down to your activity. Find the item you want to delete. You can...
Read more >
Low on Storage? Delete Your Unused Android Apps - CNET
We'll show you how to free up storage on your Samsung, Google Pixel or other Android device by uninstalling the apps you rarely...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found