Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by Pb2323 · Apr 23, 2021 at 12:52 PM · savingint

Are PlayerPrefs save or hackable on android?

Hello guys, i made a game to save ints like the money of the player. So are the PlayerPrefs save on android and IOS or can you easy change it? And when you download the game do you have access to the PlayerPrefs when you look through the storage of the Phone where the game is at?

Thx for ur help!

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
0

Answer by xxmariofer · Apr 23, 2021 at 01:16 PM

Well, everything is hackable, but player prefs is a simple file in an android directory.

 /data/data/pkg-name/shared_prefs/pkg-name.v2.playerprefs.xml
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 Pb2323 · Apr 23, 2021 at 01:18 PM 0
Share

Is there an other secure way so save an int. So they are not readable?

avatar image Llama_w_2Ls Pb2323 · Apr 23, 2021 at 03:04 PM 0
Share

You can save an encrypted file into a persistent data path on android using a binary formatter, or any serializer, that can convert C# objects into text/byte form. Here's a common example:

 using System.IO;
 using System.Runtime.Serialization.Formatters.Binary;
 using System.Text;
 
 public class SaveData
 {
     public static void Save(PlayerData data)
     {
         BinaryFormatter bf = new BinaryFormatter();
         MemoryStream ms = new MemoryStream();
 
         bf.Serialize(ms, data);
 
         var bytes = ms.ToArray();
         var text = Encoding.ASCII.GetString(bytes);
 
         // Writes data to a file
         File.WriteAllText(Application.persistentDataPath + "/PlayerData.save", text);
     }
 
     public static PlayerData Load()
     {
         // Gets data from file
         var text = File.ReadAllText(Application.persistentDataPath + "/PlayerData.save");
         var bytes = Encoding.ASCII.GetBytes(text);
 
         BinaryFormatter bf = new BinaryFormatter();
         MemoryStream ms = new MemoryStream(bytes);
 
         return (PlayerData)bf.Deserialize(data);
     }
 }
 
 [System.Serializable]
 public class PlayerData
 {
     public string Name;
     public int Level;
 }

@Pb2323

avatar image xxmariofer Pb2323 · Apr 23, 2021 at 03:05 PM 1
Share

Well, obviously the most secure way is using servers for login and retrieving data. But my suggestion, is unless you are planning a really big project, dont invest a ton of resources into making it unhackable, it will most likely be not worth it cost - benefit, creating a file in a no common directory, and using a simple encrypting agorithm would be enough usually

avatar image
0

Answer by gigos22 · Apr 23, 2021 at 02:18 PM

Yes it is very "hackable" but just because anyone can edit it on their phone.

BUT... If the user doesn't know (which they shouldn't) that your game is saved this way, it shouldn't matter.. Because the average player doesn't go to check the directory the user above me mentioned with each game the download..

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

117 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

Related Questions

what's the result of PlayerPrefs.Get... if the key/value was never set? 1 Answer

Unrelated changes in scene text file 0 Answers

How to create a save and load game proccess like SCP: Containment Breach? 0 Answers

Saving in Regedit 2 Answers

Saving players progress in ScriptableObject asset 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