unity 各平台下文件读写沙箱目录及ios审核(原)

来源:互联网 发布:subcrew淘宝专卖店 编辑:程序博客网 时间:2024/06/06 02:28

各平台目录

IOS:
Application.dataPath :                    private/var/Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data
Application.streamingAssetsPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data/Raw
Application.persistentDataPath :    Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Documents
Application.temporaryCachePath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Library/Caches

Android:
Application.dataPath :  /data/app/xxx.xxx.xxx.apk
Application.streamingAssetsPath :  jar:file:///data/app/xxx.xxx.xxx.apk/!/assets
Application.persistentDataPath :  /data/data/xxx.xxx.xxx/files
Application.temporaryCachePath :  /data/data/xxx.xxx.xxx/cache

Windows:
Application.dataPath :                         /Assets
Application.streamingAssetsPath :      /Assets/StreamingAssets
Application.persistentDataPath :         C:/Users/xxxx/AppData/LocalLow/CompanyName/ProductName
Application.temporaryCachePath :      C:/Users/xxxx/AppData/Local/Temp/CompanyName/ProductName


Mac:
Application.dataPath :                         /Assets
Application.streamingAssetsPath :      /Assets/StreamingAssets
Application.persistentDataPath :         /Users/xxxx/Library/Caches/CompanyName/Product Name
Application.temporaryCachePath :      /var/folders/57/6b4_9w8113x2fsmzx_yhrhvh0000gn/T/CompanyName/Product Name


无论 android或ios我们都可以用Application.persistentDataPath来获取沙箱路径

注意,不要使用Application.dataPath 这个在ios8以前是可读写,但ios8后,只可读不可写


沙箱内目录结构

1 android打包后的apk实际上是jar压缩包,可以用解压缩打开查看

2 ios安装后的沙箱目录

Documents 目录:这个目录用于存储用户数据,iTunes备份和恢复的时候会包括此目录

AppName.app 目录:这是应用程序的程序包目录,包含应用程序的本身。由于应用程序必须经过签名,所以您在运行时不能对这个目录中的内容进行修改,否则可能会使应用程序无法启动。

Library 目录:这个目录下有两个子目录:Caches 和 Preferences
Preferences 目录:包含应用程序的偏好设置文件。您不应该直接创建偏好设置文件,而是应该使用NSUserDefaults类来取得和设置应用程序的偏好.
Caches 目录:存放缓存文件,iTunes不会备份此目录,此目录下文件不会在应用退出删除,保存应用程序再次启动过程中需要的信息。

tmp 目录:这个目录用于存放临时文件,保存应用程序再次启动过程中不需要的信息。有可能在程序退出或设备重启后清空目录,但实测ipad下重启应用或重启设备后并没有清空

iTunes在与iPhone同步时,备份所有的Documents和Library文件。


关于审核

1 android下审核标准较低,所以不做讨论

2 ios审核时会要求Documents 下文件不可以太多,太大所。以我们要通过审核,这里只保存简单的用户信息,其它游戏信息可以保存在Library /Caches 下,我们可以在Library /Caches 下新建一个userdata目录来保存需要的信息




0 0
原创粉丝点击