+1 vote

Hi guys!

I'm working on a simple android clicker game. I need to save some data each time the game is closed, such as the current number of clicks or the number of times each upgrade item has been bought. On a PC it can be done with a simple .txt file but I can't seem to find a way to make it work on Android.

How would you go around solving this ?

Thank you for your ideas

in Engine by (25 points)

1 Answer

+1 vote
Best answer

Hey. There is no difference between saving data to a PC and an android. I saved data in json. This is more correct than just in text format.

func save_game():
    print(data_dict)
    var savegame = File.new()
    savegame.open("user://savegame.save", File.WRITE)
    savegame.store_line(to_json(data_dict))
    savegame.close()

You can also look here:
https://www.youtube.com/watch?v=XQptE6qrhKA

by (102 points)
selected by

thank you very much for your answer

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.