App doesnt load/save/create json in user:// in android

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Metamo

Hi everyone.
My app loads data from user://data.json at startup, works perfectly on windows!
I included Json-File extensions on the export tab and export it to android.
But nothing seems loaded on startup. So i print the user://-path with OS.get_user_data_dir() and this directory doesnt exist!
So it doesnt write anything and obviously load nothing.
I have more json-files in the project, which you can load with a itemlist, on win it works perfectly, on android they are no json-files.
I have tested in on a smartphone and on a tablet with an older and a newer android-version.
What did i wrong? How it is going to work?

:bust_in_silhouette: Reply From: deaton64

Hello,

I may have this all wrong, as I don’t know for sure, but I have managed to recreate sort of what you said above.
I have a file in user: on Windows, reads in to the Godot app, all is good.
Export the game to Android, run the app. No such file.

This is why I think that is.

The file only exists in user: on the Windows PC, as I put it there.
It exists in the res: directory on Android, as I exported the file as part of the project.
It doesn’t exist in user: on Android, as I haven’t put it there.

I don’t know if there’s a way of copying user: files as part of the project build, but I added a file copy as soon as the app launched and it worked as expected.

var dir = Directory.new();
dir.copy("res://test.json","user://test.json");