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
1
Question by gustavoprado · Oct 27, 2019 at 09:01 AM · androidsavedatapath

How to Savegame on Android data/data?

Hello people. I am currently developing an Android game, and I have an issue about Application.persistentDataPath. I built a save system for my game, and the file is being saved using Application.persistentDataPath.


The problem is that Application.persistentDataPath refers to Internal SD Storage in Android devices. That's not the way I'm looking for saving the player progress, because it's easy to access and share between players. I need to change the path do data/data, to make it more difficult to access (only root users can do it).


Can I manually specify the path to "data/data/com.mycompany.mygame/files"? Or is there any way to do it automatically, with or without Application.persistentDataPath? (Not using PlayerPrefs, because it's not safe for player progression).


Thanks for now and I hope someone can lead me to a solution.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by naviln · Oct 29, 2019 at 05:58 AM

there is Application.dataPath available, if you want to try that: https://docs.unity3d.com/ScriptReference/Application-dataPath.html

Although, i would suggest trying some other methods to discourage these files from being shared and reused. e.g. you may be better off trying to make it harder to load the saved data, instead of just trying to hide where it lives.


One such strategy could be to use a basic 2 way encryption on your save files. For the private key, you could use something unique or device specific, salt it and/or mix it with a secret in your binary code.


These statics might be useful for that purpose: https://docs.unity3d.com/ScriptReference/SystemInfo.html

  • deviceModel The model of the device (Read Only).

  • deviceName The user defined name of the device (Read Only).

  • deviceType Returns the kind of device the application is running on (Read Only).

  • deviceUniqueIdentifier A unique device identifier. It is guaranteed to be unique for every device (Read Only).


Grab any of those as the app launches, and encrypt your save file using a combo of them (plus some secret string/GUID in your app too, perhaps?) When loading a save game file, update your code to decrypt the save game file using those values.

Its not fool proof, but it makes it a lot harder for someone to just share files and reuse them. Especially if you combine it with a secret string or randomly generated GUID in your binary! (The idea here is obfuscation - you are making it harder to break, but not impossible).


Here is a link with some sample two way encryption in C#: https://stackoverflow.com/questions/165808/simple-insecure-two-way-obfuscation-for-c-sharp

Ultimately, anything stored client side can never be assumed secure or reliable - if you need a bullet proof solution, you will need to save progress server side, ask users to create accounts with passwords, use one way hashing (e.g. Bcrypt or something similar) and store those credentials etc. etc.

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

251 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 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 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 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

PlayerPrefs don't load again after Android game closes for the first time. 1 Answer

Application.CaptureScreenshot() does not save any image on Android while it does on Editor! 0 Answers

Playerprefs not working on android 0 Answers

Screenshot is not save properly into the folder. 0 Answers

Saving and loading to/from Android 1 Answer


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