0 votes

I'm use ConfigFile to manage user's data in game.
I get data, use it, change value and then save in ConfigFile. All this in one scene.
On Windows everything works perfectly, i can read and save file. But on Andriod i faced a problem:
My code reads the file but can't save it.

var config = ConfigFile.new()
var settings = config.load("res://settings.cfg")
if settings == OK:
    starCount = config.get_value("star", "count", null)

starCount = starCount + 10
if settings == OK:
    config.set_value("star", "count", starCount)
    config.save("user://settings.cfg")

When i'm reading with user:// path its doesn't reading on android. settings during reading and after saving is 0. I'm use Custom User Build, i tried to enable Write external storage permission, i tried to upgrade from v3.2.2 to v3.2.3, i tried manually add permission in manifest, but doesn't work, i tried to use text file, same problem. I added my ConfigFIle to Export --> Resources. I run my project on android via usb.

I would be grateful if you can help me solve the problem. Tnx!

Godot version 3.2.3
in Engine by (12 points)

I added my ConfigFIle to Export --> Resources.

You don't need to do this as the configuration file will be in user://. It won't be included in the exported PCK.

Try removing the settings == OK check and see if it works on Android this way. When you run the project for the first time, the setting file won't exist. This may make config.load() return a different value than OK.

1 Answer

0 votes

You'll need to remotely debugg your Android app as when something fails in a block of code the rest of that block seems to get ignored most likey to avoid crashes.

That said your problem may not be directly related to the saving of the config file

Tip

There's no need for the Write external storage permissions as the user:// dir is located in the application's reserved space

by (4,644 points)
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 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 webmaster@godotengine.org with your username.