Personnaly, I like to write directly into a file. It's applicable to all platforms, isn't removed on an app update, and you have full control over the way you access the data.
It's easy to add, remove, edit the contents, and easy to handle multiple save states.
You can do it with a simple class, such as this one :
public static class FileUtils
{
public static void WriteToFile(string fileName, string json)
{
var path = GetFilePath(fileName);
var stream = new FileStream(path, FileMode.Create);
using (var writer = new StreamWriter(stream))
writer.Write(json);
}
public static string ReadFromFile(string fileName)
{
var path = GetFilePath(fileName);
if (File.Exists(path))
{
using (var reader = new StreamReader(path))
return reader.ReadToEnd();
}
Debug.LogWarning($"{fileName} not found.");
return null;
}
public static string GetFilePath(string fileName)
{
return Path.Combine(Application.persistentDataPath, fileName);
}
}
And then, you just need a Serializable class or struct to save, here I use JSON :
[Serializable]
public class UserData
{
public string userName;
public string profilePictureRef;
public UserData(string userName, string profilePictureRef)
{
this.userName = userName;
this.profilePictureRef = profilePictureRef;
}
}
public void SaveUserData(UserData data)
{
var jsonData = JsonUtility.ToJson(data);
FileUtils.WriteToFile(_fileName, jsonData);
}
public void LoadUserData()
{
var jsonData = FileUtils.ReadFromFile(_fileName);
_data = JsonUtility.FromJson<UserData>(jsonData);
}
You can even fetch some JSON from a server and save it locally.
Maybe you'll want to "blur" the contents so that the player can't edit them by hand.