Jan 10th, 2025
I recently found myself needing to copy the save data from one app to another on android. This apparently used to be easy back before android 13. In 13, they added a data protection feature that prevents apps from accessing each other's files. It makes a lot of sense, but theres no easy way for the user to get around these protections.
There was a lot of info online about how to solve this, but most of it didn't work for me. Probably has something to do with the fact my phone is running android 15. I'm going to write the steps that worked for me here, to hopefully help some people trying to do the same thing.
You will need to have USB debugging and ADB set up. There's plenty of info on the web about this.
This is a simple one-liner. Replace <your-package> with the name of the package you want to get the files from. Replace <files/folders> with the files/folders you want out of the private folder.
adb exec-out run-as <your-package> tar c <files/folders> > output.tar
This one is a little more complicted. In theory, adb exec-in
should work, but it didn't for me. We
are going to use run-as
from within an adb shell. This allows us to have the same file permissions
as the package we are writing the data to, meaning we can write to it's private data folder. Unfortunately, doing
this means that we can no longer read most files on the system, such as /sdcard
. Thankfully, packages
can read from /data/local/tmp
, so we can write the file there, and copy it to the private data folder.
adb push output.tar /data/local/tmp
Now we enter the shell and run-as
the package.
adb shell
run-as <your-package>
When this is done, we will be in the private data folder. Now we just need to copy the file and untar it.
cp /data/local/tmp/output.tar .
tar xvf output.tar
Aaaand that's it! The files should now be in the new folder. Run an ls
just to be sure.
Thanks for reading.