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

Discussion in 'Android Questions' started by Devv, Jun 11, 2015.

  1. Devv

    Devv Active Member Licensed 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
    Code:
    ImageView2.SetBackgroundImage(LoadBitmap(File.DirAssets & "\Loading",i & ".jpg"))
    now it stopped working ...
    any ideas
     
  2. Mahares

    Mahares Well-Known Member Licensed User

  3. Devv

    Devv Active Member Licensed User

  4. Informatix

    Informatix Expert Licensed 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.
     
    Peter Simpson likes this.
  5. Devv

    Devv Active Member Licensed User

    yes i changed the folder name to lowercase and edited the folder name on the code
    i'am using galaxy s3, b4a 5
     
  6. Informatix

    Informatix Expert Licensed User

    I have many users with a Galaxy S3. But I don't use B4A v5, only v4.30.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    The folder parameter must be File.DirAssets. You need to add the subfolder to the file name.
     
    Informatix likes this.
  8. Mahares

    Mahares Well-Known Member Licensed User

    Instead of this:
    Code:
    ImageView2.SetBackgroundImage(LoadBitmap(File.DirAssets & "\Loading",i & ".jpg"))
    Your code should be like this (note the forward slash):
    Code:
    ImageView2.SetBackgroundImage(LoadBitmap(File.DirAssets, "loading/" & i & ".jpg"))
     
    Erel likes this.
  9. johndb

    johndb Active Member Licensed 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.
     
  10. walterf25

    walterf25 Well-Known Member Licensed User

    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.

    Code:
    ImageView2.SetBackgroundImage(LoadBitmap(File.DirAssets & "\Android\Files\Loading",i & ".jpg"))
    Hope this solves your issue.

    Walter
     
  11. Mahares

    Mahares Well-Known Member Licensed User

    It is not necessary.

    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.
     
    DonManfred likes this.
Loading...