0 votes

i'm making an android game which saves the progress to "user://data.json" file
the game crashes, probably because i haven't set the required permissions in my export settings
what options should be checked to access storage?
i have already checked Read External Storage and Write External Storage

Godot version Godot_v3.4.2-stable_win64
in Engine by (62 points)

I guess that's not the problem.
The problem is not in the options. There must be another problem

i have removed the save/load code and the game works just fine

There is a problem with the save code

heres the script i'm using

extends Node

const data_path = "user://data.json"

const default_data = {
    "bgm": {
        "bgm_collection": "city_pop",
        "current_track_index": 0

var global_data

func _ready():

func load_data():
    var file = File.new()

    if not file.file_exists(data_path):

        file.open(data_path, File.READ)
        var text = file.get_as_text()
        global_data = parse_json(text)
        # global_data = default_data.duplicate(true)


func save_data(data):
    var file = File.new()
    file.open(data_path, File.WRITE)
    global_data = data.duplicate(true)

Have you tried recording on your computer? Is it working

for example:
const datapath = "C:/Users/***/Desktop/mygame/save.json"

yes that works perfectly in my desktop

Use the remote debug in the Godot editor to find the exact line where your problem is produced

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.