June 30, 2023

Android - writing files

I am using "adb shell" to poke around on my Pixel 6. The question is where I can copy files to using "adb push". I have not rooted the phone and do not intend to.

The area /sdcard is a link to /storage/self/primary. I can do this:

cd /sdcard
df .
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/fuse      115621972 24089688  91401212  21% /storage/emulated
I am all but certain my Pixel 6 has 128G of storage. (I could have paid extra for 256G, but didn't -- and don't regret it). What I am most interested in is placing my topo map files on the Pixel 6. I used to put them on a 32G removable SD card for my previous phone. The maps actually used about 24G of space.

It looks like I have 91.4G available, which is more than adequate for the maps.

Try copying some files

I try this, and it works:
cd /sdcard
mkdir Tom
After doing this I do the following (zoot.c was just a small file I had laying around handy):
adb push zoot.c /sdcard/Tom
zoot.c: 1 file pushed, 0 skipped. 1.5 MB/s (181 bytes in 0.000s)
adb shell ls -l /sdcard/tom
-rw-rw---- 1 u0_a213 media_rw 181 2020-09-14 22:30 zoot.c
This seems too easy. And poking around I find there is even a "tar" utility on my phone, so I could push a tar file, then extract it if I wanted to move a bunch of files. Let's give that a try.
tar czvf andy.tgz gtopo.jpg green.jpg
adb push andy.tgz /sdcard/Tom
adb shell
cd /sdcard/Tom
tar xvf andy.tgz
After all of this I see:
pwd
/sdcard/Tom
ls -l
-rw-rw---- 1 u0_a213 media_rw 748534 2023-06-30 17:22 andy.tgz
-rw-rw---- 1 u0_a213 media_rw 607282 2023-03-27 17:16 green.jpg
-rw-rw---- 1 u0_a213 media_rw 142199 2023-01-31 08:34 gtopo.jpg
-rw-rw---- 1 u0_a213 media_rw    181 2020-09-14 22:30 zoot.c
Indeed, all this works just fine. The question now is whether I will encounter any trouble having an android app I write read these files.
Have any comments? Questions? Drop me a line!

Adventures in Computing / tom@mmto.org