# SDCard Path Discovery on Android ## Problem On Android 10+ and certain OEM skins, `/sdcard/` is a symlink or FUSE mount that may not be directly accessible from all contexts (especially under `su` or from Termux). The actual external storage path is often `/storage/emulated/0/`. ## Discovery Workflow When file operations on `/sdcard/` fail with "Permission denied" or "No such file or directory", run: ```bash # Check where /sdcard actually points su -c "readlink /sdcard" # May show /storage/self/primary su -c "ls -la /sdcard" # May be empty or permission denied # Check the real FUSE mount point su -c "cat /proc/mounts | grep fuse" # Typical output: # /dev/fuse /storage/emulated/0 fuse ... # /dev/fuse /mnt/user/0/emulated fuse ... # Check EXTERNAL_STORAGE env var su -c "echo $EXTERNAL_STORAGE" # Usually /sdcard # Verify the actual path works su -c "ls -la /storage/emulated/0/" ``` ## Resolution Always use `/storage/emulated/0/` as the canonical path for VisualAgent directories: ```bash # Correct COMMANDS_DIR="/storage/emulated/0/VisualAgent/commands" RESULTS_DIR="/storage/emulated/0/VisualAgent/results" # May fail depending on context COMMANDS_DIR="/sdcard/VisualAgent/commands" ``` ## In Practice This session encountered the issue where: 1. `mkdir -p /sdcard/VisualAgent/commands` failed with "Permission denied" 2. `su -c "mkdir -p /sdcard/VisualAgent/commands"` succeeded but created at `/storage/emulated/0/VisualAgent/commands` 3. The command files were actually at `/storage/emulated/0/VisualAgent/commands/` 4. `read_file` and `write_file` tools failed on `/storage/emulated/0/VisualAgent/` paths with "Permission denied" 5. Only `terminal` with `su -c` worked for file operations ## Key Takeaway For Android automation backends, always: - Use `/storage/emulated/0/` as the canonical external storage path - Use `su -c` for all file operations on external storage - Use `terminal` tool (not `read_file`/`write_file`) when running in Termux/cron context - Test path accessibility with `su -c "ls -la /storage/emulated/0/"` before assuming it works