在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