Question

I have a folder in my resource folder called "tiles'. I want to be able to add or remove tiles as I develop this game, which could hold hundreds. Therefore - for the map editor I am making - I want a simple way to load these into an array (the names, at least) and then display them into an appropriate view (surface?) at runtime. Preferably in grid format, i.e. 3 across and then infinite vertically based on a for loop or whatever.

Was it helpful?

Solution

To list the files on a folder, you can use this and it will return an array of File object.

File dir = new File(Environment.getExternalStorageDirectory() + "/your/directory/on/sdcard/");
File[] files = dir.listFiles();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top