Files in user:// for an Android project not showing up

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

I have a small test Godot 4 targetting Android with only the following code.

func _ready():
    FileAccess.open("user://made_in_godot.txt", FileAccess.WRITE)
    %Label.text = str("Files: ", DirAccess.get_files_at("user://"))

After running this once, I removed the first line writing made_in_godot.txt. All subsequent runs of the program only read files in user:// and update the label’s text accordingly.

Running the project created a directory on my Android device.

Internal shared storage\Android\data\org.godotengine.test\files

Within this directory, using my PC’s File Explorer, I copied over a second empty text file called made_within_filesystem.txt

At this point, I notice a discrepancy. When running the Godot project on my Android device, it only sees made_in_godot.txt and not made_within_filesystem.txt.

enter image description here

Similarly, when navigating to the project’s user:// folder in File Explorer, I can only see made_within_filesystem.txt and not made_in_godot.txt.

enter image description here

Additionally, searching for made_in_godot.txt in File Explorer yields no results. It is like the file system does not think the file exists. However, it must be somewhere because the Godot project is able to see it. Further, all this works fine when running on PC; both the Godot project and the file system show both files. What could be going on?

On the surface, this feels like a permissions-related issue. I can only assume the permissions and/or ownership of the two files differ based on the methods used to create them…

jgodfrey | 2023-03-06 20:34

1 Like

For anyone still running into this, the solution is to give your Android/Quest program the MANAGE_EXTERNAL_STORAGE permission. This will allow it to access all files in the Internal shared storage area on the device.

Android will popup a scary-looking permissions dialog, but you will then be able to read files places there by your operating system file manager.