运行 android 和快速启动如何获得相同的存储路径?

How to get same storage path for running android and fast boot?

我尝试为我的自定义 rom 制作更新程序。

有我用来刷新更新的代码

private void flashRom() throws IOException {


        Process p = Runtime.getRuntime().exec("su");
        OutputStream os = p.getOutputStream();
        os.write("mkdir -p /cache/recovery/\n".getBytes());
        os.write("echo 'boot-recovery' >/cache/recovery/command\n".getBytes());
        os.write("reboot recovery\n".getBytes());


        os.flush();
    }

而且通常效果很好。我的问题发生在某些设备上,其中 /sdcard/ 被称为 /mnt/media/getExternalStorageDir() returns /storage/emulated/0/.. 对于同一设备,我使用下载管理器将文件保存到 request.setDestinationInExternalPublicDir("rom", "update.zip"); 我必须在哪里保存下载的更新或我如何确保 getExternalStorageDir()(或更合适的方法)将 return 与 fastboot 中的 /sdcard/ 相同的路径?

我使用 TWRP 恢复而不是 CWN,它正确识别路径