Retain app data after uninstall

Generally, as soon as the user uninstalls an application, application data is removed from the Android operating system.
This data includes the app data stored in the internal storage of the device, typically /data/data/{package_name} and the application-specific directory on the external storage. Refer to the official documentation to learn more about storing data on Android.

In Android 10, a new Manifest flag called hasFragileUserData is added. Adding this flag to the manifest file gives end-users and option to retain application data even after the application is uninstalled.

Where to add this flag?

This flag should be added inside the application tag of the Manifest file.

Before adding this flag to your Manifest file make sure you have bumped up the compileSdkVersion and targetSdkVersion to API level 29

How will it be shown to the users?

When uninstalling the application users will see a checkbox in which they can check and retain the application data on the device even after the application is uninstalled.

Option to retain app data

What data will be retained?

Data stored in the internal storage i.e. /data/data/{package_name} and the data stored on the Application-specific storage on the external storage will not be removed from the device.

--

--

Technical Lead @MoEngage

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store