Android Question Access to files in b4a 10.70 BETA # 2

coldteam

Active Member
Licensed User
Longtime User
Trying a new beta b4a and a question arose.
I use LibGdx in my projects, and I used to store files like this: (This is just an example)
Files/
npc/goblin.png
monsters/goblin.png
player/player1.png
player/player2.png
I have stored files in different folders and downloaded them asynchronously via asset manager.
I have not used the File Manager built into b4a in any way.
In the new beta version, I get the error, the file cannot be downloaded with this address. As in the screenshot.
When I add a file through the File Manager, it is located in the root directory of the project's Files folder.
If I understand correctly, now it will not work to use folders for this, and you just need to divide files into groups, but only in the built-in File Manager B4A.

As a result, there cannot be 2 files with the same name in one project. Correct me, maybe I didn't understand how it works.

The main question is how to access files in subfolders in the new version 10.70.
 

Attachments

  • 321123.jpg
    510.1 KB · Views: 201
Last edited:

coldteam

Active Member
Licensed User
Longtime User
Does this code work with directories (I mean: does it return true for an existing directory and false for a missing one) ? And how do I retrieve the list of assets ?

i mean this, the code is up to date and works in android studio with new sdk.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The change is related to AAPT2, the packager tool.

This code is from File.OpenInput:
B4X:
if (Dir.equals(assetsDir)) {
            if (virtualAssetsFolder != null) {
                is.setObject(new GZIPInputStream(
                        new FileInputStream(new java.io.File(virtualAssetsFolder, FileName.toLowerCase(BA.cul)))));
            }
            else {
                is.setObject(BA.applicationContext.getAssets().open(FileName.toLowerCase(BA.cul).replace('/', '\\')));
            }
        }
The backward slash is replaced with a forward slash now.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Upvote 0

Informatix

Expert
Licensed User
Longtime User
This call always returns an empty list with the new version, which is not expected:
BA.applicationContext.getAssets().list(FileName.toLowerCase(BA.cul).replace('/', '\\'))
In the previous version, all files in the specified directory were returned.
 
Upvote 0

coldteam

Active Member
Licensed User
Longtime User
This call always returns an empty list with the new version, which is not expected:
BA.applicationContext.getAssets().list(FileName.toLowerCase(BA.cul).replace('/', '\\'))
In the previous version, all files in the specified directory were returned.

It's good if at this step we don't get the list. I think @Erel can help us with this.
 
Upvote 0

coldteam

Active Member
Licensed User
Longtime User

Thank! Yes, the difference is enormous. I tested this at 10.60 10.70#3
Now this function gets the whole list of files.
Files inside a folder. And at 10.60, only the folder was visible.

B4X:
begin
1.png
2.png
3.png
images
test\1.png
test\1.txt
webkit
end
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…