Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Possible to preserve data when upgrading app?

Tags:

android

Is it possible to preserve file-persisted data when upgrading an app? For example my app stores data under /data/data/mypkg/store. I would like the store directory to be preserved when user upgrades my app.

like image 703
zer0stimulus Avatar asked Dec 22 '22 23:12

zer0stimulus


2 Answers

Application data is not deleted when upgrading apps. It is only removed when they are uninstalled

like image 171
smith324 Avatar answered Dec 24 '22 11:12

smith324


Please refer to adb documents.

adb install [-l] [-r] [-s] - push this package file to the device and install it
                               ('-l' means forward-lock the app)
                               ('-r' means reinstall the app, keeping its data)
                               ('-s' means install on SD card instead of internal storage)
adb uninstall [-k] - remove this app package from the device
                               ('-k' means keep the data and cache directories)

Add '-r' when you reinstall.
Add '-k' when you uninstall.

like image 36
Jett Hsieh Avatar answered Dec 24 '22 13:12

Jett Hsieh