persistentDataPath
Contains the path to a persistent data directory (Read-only).
Read time 2 minutesLast updated 4 days ago
Definition
- Type: Property
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public static string persistentDataPath { get; }
Remarks
This value is a directory path where you can store data that you want to retain between runs. When you publish on iOS and Android, points to a public directory on the device. The files can only be erased by users directly and not by any app updates. Note: The difference slashes indicate the different operating systems according to DirectorySeparatorChar.
persistentDataPathWhen you build the Unity application, a GUID is generated that is based on the Bundle Identifier. This GUID is part of . If you keep the same Bundle Identifier in future versions, the application keeps accessing the same location on every update.
persistentDataPathUWP Apps: Application.persistentDataPath points to .
C:\Users\<user>\AppData\LocalLow\<company name>Windows Editor and Windows Player: Application.persistentDataPath usually points to . It is resolved by SHGetKnownFolderPath with FOLDERID_LocalAppDataLow, or SHGetFolderPathW with CSIDL_LOCAL_APPDATA if the former is not available.
%userprofile%\AppData\LocalLow\<companyname>\<productname>Web: Application.persistentDataPath points to a location in the browser's IndexedDB file system. The path is formed as , where is an MD5 hash generated from the URL of the directory containing the application's web page. The specific filename (for example: ) and any URL query parameters don't alter the persistent data path.
idbfs<hash><hash>index.htmlLinux: Application.persistentDataPath points to , where defaults to .
$XDG_CONFIG_HOME/unity3d/Company/ProjectName$XDG_CONFIG_HOME~/.config</c>. For example: <c>~/.config/unity3d/CompanyName/ProductNameiOS: Application.persistentDataPath points to .
/var/mobile/Containers/DataApplication<guid>/DocumentstvOS: Application.persistentDataPath is not supported and returns an empty string.
Android: Application.persistentDataPath points to on most devices (some older phones might point to location on SD card if present), the path is resolved using android.content.Context.getExternalFilesDir.
/storageemulated<userid>/Androiddata<packagename>/filesmacOS Editor: Application.persistentDataPath points to .
~/Library/Application Support/company name/product namemacOS Player: Application.persistentDataPath points to , but uses the Editor path if that directory already exists.
~/Library/Application Support/unity.company name.product nameSaving files to this path: Some Unity APIs (for example, ScreenCapture.CaptureScreenshot) interpret relative paths as relative to the project directory on Windows Editor and other non-mobile platforms, not relative to . Therefore, screenshots or other files saved with a relative path end up in the project folder, not in on Windows. To save files to the persistent data path, pass a full path: .
persistentDataPathAppData/LocalLowSystem.IO.Path.Combine(Application.persistentDataPath, "filename.png")Examples
using UnityEngine;public class Info : MonoBehaviour{ void Start() { Debug.Log(Application.persistentDataPath); }}