Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Android 10 Lets Developers Ask Users If They Want To Retain App Data Before Uninstalling

Android 10 is the latest update for Android from Google and brings some improvements to the mature operating system. Most changes and new features in the latest update are either highlighted by Google itself during Google I/O or are found shortly after public release.

But some notable changes tend to get under the radar and show up months later when someone accidentally bumps into them. This happens in this case because Android 10 allows developers to ask their users if they want to keep the app data before their app is uninstalled.

A recent report by AndroidPolice highlighted this functionality. Apps like WhatsApp and ASR Voice Recorder now give Android 10 users the ability to keep the data of an app to be uninstalled.

Android 10, Retain App Data Before Uninstalling

Checking the box above will keep the app data on the phone, even though the app will be uninstalled. When you reinstall the app, you’ll be back in the same state in the app as if you’d never uninstalled it.

We have done a bit of research on what’s going on behind the scenes. To understand this, you’ll first need to understand how apps on Android can store files on your device, and there are three main file locations:

  • App-specific Directory in the internal (user-inaccessible without root) storage: These folders are located at /data/data and are not accessible to other apps, or when the user ordinarily plugs their phone into a PC. Apps do not need permission to write files to their own app-specific directory in this location.
  • App-specific Directory in the external (user-accessible) storage: These folders are located at /data/media/{user}/Android/data and are accessible to other apps with the right permission, and to the user when they ordinarily plug in their phone to a computer.
  • Apps do not need permission to write files to their own app-specific directory in this location, but they do need permission to access data from other apps, as mentioned previously.
  • Any directory in the external (user-accessible) storage: Apps can request permission to access the external storage, allowing the app to create whatever folder it needs to on the external storage to store whatever it wants to store here.

As an extension of the WhatsApp example, WhatsApp’s App-specific directory resides in internal storage at /data/data/com.whatsapp. The app-specific directory in external storage is located at /data/media/{user}/Android/data/com.whatsapp. The custom directory in external storage is located at / data / media / {user} / WhatsApp.

If a user uninstalls an app from Android 10 and from developers who enable it for their apps, their app-specific directories will be deleted by default in both internal (/data/data) and external (/data/media) memory. The additional directories on the external storage are not deleted, and you must manually remove them or use an app like SD Maid to do this for you.

With Android 10, app developers can add a special flag called “hasFragileUserData” to their manifest, which lets them ask the user whether to keep the app’s data when uninstalling the app.

This is shown in the screenshot above. If you uninstall an app and select the checkbox to keep the app data, Android retains the app-specific directories in internal and external storage and does not delete them.

We confirmed this by looking in the directories for apps that did not add the manifest flag and for apps like WhatsApp that added the manifest flag.

On the surface, this option makes sense, since users can temporarily uninstall apps and still return to their previous state after the reinstallation, which may save some problems with backing up and restoring the app on the same device.

Note, however, that accessing /data/data without root is not possible, so as a user you will not be able to use this process for cross-device backup and non-root restore. It is also not possible for users to delete the files left in /data/data without root.

So if you want to delete the files in the future, you will have to reinstall the app and then uninstall it without checking the box.

If you use this option for too many apps, you’ll probably forget which apps you’ve selected as the user.

Since this is optional for developers and optional for users, we believe this is an overall positive change that gives the end-user more power.

News Source – XDA developers

Don’t forget to check this out – Samsung Galaxy S11 With 2nd-Gen 108 MP Sensor