在HarmonyOS应用开发中,通过Content获取文件沙盒路径时,会随不同的context和module而不同(developer.huawei.com/consumer/cn…获取应用文件路径)
其中filesDir(cacheDir、preferencesDir、tempDir等)生成的路径中会在以下场景下发生变化:
当项目采用多HAP(Harmony Ability Package)模块结构时,每个模块会拥有独立的filesDir路径。例如:
-
主模块(通常命名为entry)路径:/data/storage/el2/base/haps/entry/files
-
功能模块(如feature模块)路径:/data/storage/el2/base/haps/feature/files