Android Question can i put a folder in File.DirAssets ?

Devv

Active Member
Licensed User
Longtime User
I have lots of files in my File.DirAssets
so i decided to organize them into folders
i made a folder in "\Android\Files\Loading"
i put some files in "Loading" folder, then i edited my code to
B4X:
ImageView2.SetBackgroundImage(LoadBitmap(File.DirAssets & "\Loading",i & ".jpg"))
now it stopped working ...
any ideas
 

Devv

Active Member
Licensed User
Longtime User
Do you have an example of device ? Because my first app on Google Play runs without issue on a lot of different devices and has many subfolders in the assets. As suggested, their name is in lowercase.
yes i changed the folder name to lowercase and edited the folder name on the code
i'am using galaxy s3, b4a 5
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Instead of this:
B4X:
ImageView2.SetBackgroundImage(LoadBitmap(File.DirAssets & "\Loading",i & ".jpg"))
Your code should be like this (note the forward slash):
B4X:
ImageView2.SetBackgroundImage(LoadBitmap(File.DirAssets, "loading/" & i & ".jpg"))
 
Upvote 0

johndb

Active Member
Licensed User
Longtime User
If I am not mistaken, I think you also have to put the following directive in your main #DebuggerForceStandardAssets: true if you want to access your folders during debug sessions.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
I have lots of files in my File.DirAssets
so i decided to organize them into folders
i made a folder in "\Android\Files\Loading"
i put some files in "Loading" folder, then i edited my code to
B4X:
ImageView2.SetBackgroundImage(LoadBitmap(File.DirAssets & "\Loading",i & ".jpg"))
now it stopped working ...
any ideas

I think the problem is that you are confusing the directories:
"\Android\Files\" directory is not in the Files.DirAssets but in the file.DirDefaultExternal directory.

Now if you created the \Android\Files\Loading\ directory in the File.DirAssets directory then your code should look like this.

B4X:
ImageView2.SetBackgroundImage(LoadBitmap(File.DirAssets & "\Android\Files\Loading",i & ".jpg"))

Hope this solves your issue.

Walter
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
If I am not mistaken, I think you also have to put the following directive in your main #DebuggerForceStandardAssets: true
It is not necessary.

ImageView2.SetBackgroundImage(LoadBitmap(File.DirAssets & "\Android\Files\Loading",i & ".jpg"))
I am afraid that is not the correct syntax if you are dealing with the assets folder or its subfolder. See post #8 for the correct code, tested and works.
 
Upvote 0
Top