Saving game data on Android

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LG

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

:bust_in_silhouette: Reply From: Bakz

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:

thank you very much for your answer

LG | 2020-04-25 01:29