File reading/writing isn’t working on Android app. Works fine on Windows build.
Using default configuration for building apk with enabled permissions for read and write external storage.
Code
extends Node
const SAVE_PATH = "user://save_game.dat"
func saveGame():
var file = FileAccess.open(SAVE_PATH, FileAccess.WRITE)
var data = {
"Gold" : Game.Gold,
}
var jstr = JSON.stringify(data)
file.store_line(jstr)
func loadgame():
var file = FileAccess.open(SAVE_PATH, FileAccess.READ)
if FileAccess.file_exists(SAVE_PATH):
if not file.eof_reached():
var current_line = JSON.parse_string(file.get_line())
if current_line:
Game.Gold = current_line["Gold"]
elif FileAccess.file_exists(SAVE_PATH) == false:
saveGame()
loadgame()
func _on_ready():
#saveGame()
loadgame()
Thanks for sharing, I’ve rewritten the code for this plugin, however it still has the same problem. On my windows it works fine, however on my android device it is the same problem, not working
I tried on an emulator but the app stops when launching, so can’t really test it that way. Haven’t tried it on another physical device, will try to do it as soon as I can.
sorry, I’m not quite sure what you are referring to as the rendering mode.
Rendering method is Mobile and the Rendering device is Vulkan, if you are referring to any of them
Thank you, I managed to fix it.
The problem was that there were problems with script attaching. Detaching and attaching a new script seems to have fixed the issue. The script wasn’t loading properly on android for some reason.