【问题标题】:Saving game progress files at path /storage/emulated/0/namefolder is this really allowed to do?将游戏进度文件保存在路径 /storage/emulated/0/namefolder 真的可以这样做吗?
【发布时间】:2017-01-27 03:04:09
【问题描述】:

我正在为 Android 开发 Unity 游戏,我正在使用标准的不同文件夹应用程序路径。persistentDataPath 来保存我的游戏进度、硬币等。我这样做是因为如果有人卸载游戏,文件受到保护,游戏进度不会丢失,因为 Application.persistentDataPath 文件夹文件被删除。

我可以在不同的文件夹中写入和读取游戏进度,但我的问题是:这真的允许我们这样做吗?违反任何使用政策?或者它可能以任何方式有害?

【问题讨论】:

  • 是的,这是允许的。但是您的问题包含硬编码路径。不要使用硬编码路径。你最好问问你是否可以使用getExternalStorageDirectory()。它提供了一条在设备之间不同的路径。
  • Application.persistentDataPath + "/../../namefolder/" + 文件名可能吗?
  • Application.persistentDataPath 是什么意思?我告诉过你使用 getExternalSorageDirectory()。请对此作出反应。

标签: android file unity3d path save


【解决方案1】:

是的,android 设备允许从外部存储读取和写入数据。如果游戏被删除,您的要求也是如此,但游戏状态不应丢失。所以你应该将数据写入外部存储(而不是sd卡,因为sd卡也可能在几天后被移除)。

  1. Environment.getExternalStorageDirectory() //它返回根目录。
  2. Environment.getExternalStoragePublicDirectory()//返回具体目录
  3. 如果您在外部存储中写入,它也将被其他应用程序访问。

【讨论】:

    【解决方案2】:

    是的,你可以这样做。不,它不会违反任何政策,除非您尝试修改与您的应用无关的其他文件,或者创建大量无用的文件,无用地占用大量内存。

    您应该确保用户无法访问该文件并修改或删除它,并且当用户想要卸载应用程序时,不会有任何剩余文件。

    【讨论】:

    • make sure that the user can't access the file and modify, or delete it,。为什么?用户可以。没关系。不要打扰。 when the user wants to uninstall the app, there won't be any leftovers files.。废话。 OP 专门要求提供一个文件在卸载后仍然存在的地方。
    • 好像我误解了这个问题。
    猜你喜欢
    • 1970-01-01
    • 2021-05-30
    • 2020-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-09
    • 2022-01-17
    相关资源
    最近更新 更多