0 votes

I am unable to save or load file when deploying my app on Android.

I am using the File class and the user:// directory.

I do not see any need for special Android permission for this use case.

Message when running the app on Android indicate a "file does not exist", but not much more.

In Android Log:
E/AwareLog: AtomicFileUtils: readFileLines file not exist: [email protected]

Anyone having the same problem ?

Thanks !

Godot version 3.5
in Engine by (12 points)
edited by

Generally speaking, that should work fine. Does the app save correctly on a non-Android system? Perhaps you can share your save code?

I just find out that the problem is not directly related to the saving/loading operations.

It has to do with the fact that I was trying to save a file in the _exit_tree() function. It works on Mac and Windows, but not on Android.

func _exit_tree():
    saveGame()

Here is my solution :

func _notification(what):

    if (what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST
        or what == MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST
        or what == MainLoop.NOTIFICATION_APP_PAUSED
        or what == MainLoop.NOTIFICATION_WM_UNFOCUS_REQUEST
        or what == MainLoop.NOTIFICATION_WM_FOCUS_OUT):

            saveGame()
            get_tree().quit()

func _exit_tree():
    get_tree().notification(MainLoop.NOTIFICATION_WM_QUIT_REQUEST)

Hello, Does this method apply to all types of Android?

Please log in or register to answer this question.

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.