DEV Community

Theara
Theara

Posted on

How to keep data when user was uninstall app on android device (Java)?

Top comments (2)

Collapse
 
phlash profile image
Phil Ashby

Hi Theara, welcome to DEV πŸ˜„!

I'm sure some of our more experienced #android devs will be along in a moment, however my understanding of how this is intended to work is via a backup strategy - specify that your app requires data backups in the manifest, and let Google do the work. When your app is (re)installed, any user backed-up data is also restored with it. Alternatively, create your own mechanism that saves data to a shared file (not app-local storage), then checks for / loads from the shared file on application startup. Be careful with on-device backups though, they provide an attack surface into your application!

Collapse
 
lautaronores profile image
Lautaro Nores

backup service by specifying in your manifest that your app requires data backups. This allows Google to handle the backup and restoration of user data when the app is uninstalled and reinstalled.

Another option is to implement your own data backup mechanism. This could involve saving data to a shared file (not app-local storage) and then checking for and loading from that file upon application startup.

However, it's important to be cautious with on-device backups, as they can potentially expose your application to security risks. Always prioritize the security of your users' data when implementing backup strategies.

I hope this helps, and best of luck with your app development journey!