Directory class don't see .png files in android

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

So i tried doing something with the images in a directory. I used the following code that mostly comes default as an example in godot -

func add_thumbnails(path):
var dir =
if == OK:
	var file_name = dir.get_next()
	while file_name != "":
		print(file_name , "  is filename")
		if !dir.current_is_dir() and file_name.ends_with(".png") and !file_name.begins_with("-"):
			print("Found file: " + file_name)
		file_name = dir.get_next()
	print("An error occurred when trying to access the path.")

This is working fine in pc, but when i run it on android( using the small android icon at top right), the print statement only prints image.png.import files and not the images itself –

5.png.import is filename
6.png.import is filename
7.png.import is filename
9.png.import is filename

so it never runs the add_texture rect() function inside the if condition. here’s the code for the path argument(just a string) :


any help ?

And the .png files are in the android file system to find?

spaceyjase | 2023-01-18 11:25

See my answer to a related question here:

Cannot traverse asset directory in Android? - Archive - Godot Forum

jgodfrey | 2023-01-18 15:58