6

Is there a way to use adb uninstall on the apk, but make the data persist? I've lost the original key to my app, and now I would like to update it, but without losing the previous data. So I need to uninstall it first to add the new apk with the new key. Is this possible?

I forgot to mention I'm executing commands via a .bat file.

3
  • Can't you adb pull /data/data/<package_name> files and then uninstall?
    – Shark
    Oct 5, 2012 at 15:18
  • @Shark I think I could do this, but can I do this using a .bat file? And insert in the device the same way I removed by using push? Oct 5, 2012 at 15:20
  • I don't see a reason why not.
    – Shark
    Oct 5, 2012 at 15:23

4 Answers 4

4

EDIT: Should have specified, the following will work only for Android 4.0 and above.

Just enable adb access, and use this command:

adb backup -noapk -f /backup/myAppBackup.ab com.yourapp.packagename

You should then have a file stored in your root directory (on Windows, your C:\ or equivalent) in a folder called backup.

Once you have this file, assuming the package name stays the same, you should be able to simply use the command

adb restore /backup/myAppBackup.ab

to restore the data.

Now, I don't know for certain that this will work once you've changed the key, but I'm fairly certain it relies only on the package name, so the signature key shouldn't matter. More info here.

3
  • Thanks, the first command created the backup, but it seems it isn't making the backup. I tried via adb shell and it says "unable to connect for backup" Oct 5, 2012 at 16:12
  • Weird thing is I don't see the backup request screen in the guide you posted. Oct 5, 2012 at 16:18
  • What operating system are you running? This only works on 4.0 and above. Oct 5, 2012 at 16:39
2

Batch-friendly version.

My-make-clean.bat:
adb pull /data/data/com.blah.bla/file1 file1
adb pull /data/data/com.blah.bla/file2 file2
adb pull /data/data/com.blah.bla/file3 file3
...
adb uninstall com.blah.bla
adb install YourApkFile.apk
0
0

If your data stored public,it will be remains after uninstalling,but if your data stored private,your data will be removed when you uninstall your App.

-1

If your device is rooted, you can access /data/<package_name> containing the app data, and you can make a backup of it.

If your device isn't rooted, you have no other means to keep your data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.