Reading and writing in a package's private data folder in android
+ +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.
+ +Getting data out of a package's private data folder
+ +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
Putting data into a package's private data folder
+ +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.
+ + + + diff --git a/style.css b/style.css index 6eabd148..6de3fb82 100644 --- a/style.css +++ b/style.css @@ -85,6 +85,14 @@ figcaption { font-size: 23px; /* this sucks but i cant find a better way */ } +nav p { + margin-top: 0px; +} + +nav h3 { + margin-bottom: 0px; +} + /* .buttons img { margin: 2px; } */ @@ -97,4 +105,4 @@ figcaption { ::selection { color: #111318; background: #F47D7B; -} \ No newline at end of file +}