Transferring files between your computer and your phone/table is a fun activity, for which you will find many solutions on the net.
In this post, I will explain how I do it using rsync. I’m assuming you know how rsync works and you’re savvy enough with rsync to not delete your entire filesystem.
This assumes your phone is connected with your PC, e.g. with an USB cable (I think bluetooth might also work), and that you can access your phone with adb (for example with adb shell).
The idea is to install a rsync binary on your phone.
First you need to find the architecture of your phone. First launch adb shell
and from it the command
uname -m
In my case, the answer is aarch64
. The next step is to find a static binary of rsync for this architecture. You can find some on the web, or you can recompile it.
Then install rsync in some directory in your android where you have write access and exec access. On my phone, I put it in /data/local/tmp
:
adb push rsync /data/local/tmp/
Now, if you want to access your phone from your computer, say to transfer anything from the directory photos to your computer, you can type the following:
rsync -e "adb shell" --rsync-path=/data/local/tmp/rsync -av exec:/sdcard/photos /photos
In practice, you might need more options for rsync, but, again, I’m assuming you already know how it works.
Remarks
- There are a few tutorials for doing this on the net. If you look at old posts, they will usually be more complicated because
adb shell
used to do CR/LF conversions which means your files and commands will become mangled while passing through adb. This is not a problem anymore.