Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | spacegrey |
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!
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
.
Calinou | 2021-02-14 02:17