Android save on quit. Godot 3.1.2

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

Upgraded to 3.1.2 and when I export to android common save quiting doesnt work, is there any other way? does it work for you?:

func _ready() -> void:
	get_tree().set_auto_accept_quit(false);
    loadState();

func _notification(what):
	if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST or what == MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST:
		print("quiting");
		saveState();
		yield(get_tree().create_timer(.1), "timeout");		
		get_tree().quit();

What is the content of saveState() ? Where do you save your data?

Android does not allow saving to i.e. ‘res://’ always save to some path below 'user://’

wombatstampede | 2020-01-10 14:21

unfortunatly it is ‘user://’.
For clarity if I manually call saveState() it works as expected on android

sciro | 2020-01-10 16:53

:bust_in_silhouette: Reply From: MrMrBlackDragon
func _on_Main_tree_exiting():
	pass # Replace with function body.

This function is called when the tree is leaved e.g when you close your game.