Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
7
Question by siddharth3322 · May 05, 2016 at 08:41 AM · androidiosfileapplicationdatapath

Difference between Application.persistantDataPath Vs Application.dataPath

As per my title suggest, I want to know difference between these two. Which one support in mobile device?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
18
Best Answer

Answer by Bunny83 · May 05, 2016 at 09:48 AM

Like the documentation of dataPath shows it simply returns the path to your "game". This depends on the platform you run on.. But as a few examples:

  • in the editor it returns the path to the Assets folder inside your project folder.

  • in a standalone build it returns the path to the "data" folder where the game data is packed into Unity's custom asset format.

  • in an Android build it points to the APK file of your app.

The usage of dataPath has to be differenciated between "editor use" and "runtime use". In the editor you would use this path only in editor scripts. Runtime scripts should keep in mind what this path is used for in the build version. The Assets folder doesn't exist in a built game. At runtime you might want to use that path to manually load / access resources that you manually ship along with your build.

I just like to add the streamingAssetsPath here. The StreamingAssets are relatively new and allow you to put some files in the special "StreamingAssets" folder in your project. Those files won't be converted into Unity's asset format but simply shiped along with your build. The "streamingAssetsPath" returns the path to that folder at runtime. Keep in mind that there are some differences on some platforms. On Android those files will be inside a folder inside your APK archive. However the WWW class is able to read those with a special file path. Just read the docs if interested.

Finally there's the persistentDataPath. As the name suggests this returns a path where you might want to store files at runtime which should persist. Things like config files, savegame files, ... should be stored under that path. The actual path is different on each platform. It's usually based on the systems preferred storage location. On Windows for example it will be a folder in AppData.

Note: In the editor it also returns a path to a persistent folder, however that is usually only used when testing in the editor. So things created while testing in the editor won't show up at runtime. If you want to know the actual path, just use Debug.Log to print the path to the console.

If you have large amounts of web streamed data (images, videos, sounds, ...) you could use temporaryCachePath to store it temporarily for later use. Keep in mind to not store things there that can't be recovered from an alternate source.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image siddharth3322 · May 05, 2016 at 09:52 AM 0
Share

@Bunny83, for mobile platform which one I need to use?

avatar image Bunny83 siddharth3322 · May 05, 2016 at 10:38 AM 0
Share

It depends on what you need the path for ^^. You only asked for the difference between those two things. You did not mention any usecase. Actually "dataPath" has less use for most applications. In most cases you probably want to use "persistantDataPath" (for storing and retrieving files) and "Strea$$anonymous$$gAssets" for things you want to ship with your game.

avatar image siddharth3322 Bunny83 · May 05, 2016 at 10:49 AM 0
Share

@Bunny83, thanks for your reply, I got my answer :)

avatar image
1

Answer by abhinandand91 · May 05, 2016 at 10:50 AM

It depends on your requirement .. its not platform specific.. Of you want the Path starting from Assets directory then Application.dataPath

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

75 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Path for Assets/Textures folder File in Android 2 Answers

Application.dataPath + "/Raw" not loading texture on iOS? 0 Answers

File Read-Write Error in iOS 1 Answer

File paths on Android 0 Answers

How do I find a folder I can write data to on Android? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges