how to prevent overwrite previously created file

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

I have a game that I have installed from the play store and the application creates a file when it starts. the problem is that when i do an update to the game the old save file gets deleted or overwritten. how can i fix this?

my file code in global script:

var save = {
	"value1": 1,
	"value2": 1,
	"value3": 1,

	}
func _ready():
	load_data()
	save_data()
	
func save_data():
	var file = File.new()
	file.open("user://save77", file.WRITE_READ)
	file.store_var(save)
	file.close()

func load_data():
	var file = File.new()
	if not file.file_exists("user://save77"):
		return false
	file.open("user://save77", file.READ)
	save = file.get_var()
	file.close()
	return true

You can save it online online or use custom dir that doesn’t deleted with app. Learn how to do it here (GitHub/Godot/Issues), EXOMODE’s comment contains the answer

USBashka | 2021-08-22 13:21

:bust_in_silhouette: Reply From: Wakatta
func save_data():
    var file = File.new()
    if not file.file_exists("user://save77"):
        file.open("user://save77", file.WRITE_READ)
        file.store_var(save)
        file.close()