Android Question File.DirAssets - using with subdirectories and htm links

JoeR

Member
Licensed User
Longtime User
I want to include some files with my .apk (on the files tab). These files are
structured in subdirectories (see examples below)
Q1 When these files are placed (automatically) in " File.DirAssets " will the subdirectory structure be retained, or will they all be placed in the root within File.DirAssets?

Q2 (if it is necessary to recreate the subdirectory structure) My filenames are prepended with the subdirectory. Can any kind person suggest the code necessary to copy the files and place them in subdirectories within File.DirDefaultExternal.

Example filenames and structure as follows.
rootone.jpg
/russ/ russtwo.jpg
/mall/ mallthree.jpg

Q3
I want to use a webview and include these images using the following links. Will they work?

B4X:
"file://"    &  File.DirAssets   &  "/russ/russtwo.jpg"

OR
"file://"    &    File.dirDefaultExternal  &    "/russ/russtwo.jpg"

 

DonManfred

Expert
Licensed User
Longtime User
I cannot give more answer. But at a quick search i found this post from erel saying that the dir.assets have no subfolders.
So i would think the files are ALL in Assetsfolders root or even are not copied due to that they are NOT in the Files-Folder of your Project directly.

To Q1: The files are copied completely to the Asset (with subfolders). You can NOT access subfolders in DirAssets so you should copy all files to projectdir/Files/ without Subfolders.

What i tried. I put a copy of a folder medicoicons\ with some images insige to projectfoldder\Files\medicoicons\ (and here some images)

with

B4X:
    Dim flist As List
    flist = File.ListFiles(File.DirAssets)
    For i = 0 To flist.Size - 1
    Log(flist.Get(i))
    Next

I got

images
medicoicons
sounds
webkit

So i tried to look inside the folder medicoicons

B4X:
    Dim flist As List
    flist = File.ListFiles(File.DirAssets&"medicoicons\")
    For i = 0 To flist.Size - 1
    Log(flist.Get(i))
    Next

i have tried File.ListFiles(File.DirAssets&"medicoicons\") in some combinations. With \ at beginning, mit / at beginning. with \

With no luck. But maybe i´m doing it wrong (i´m beginner)

To Q3: I´m not sure but i think -IN A WEBVIEW - they are both possible. The second more than the first one.
 
Last edited:
Upvote 0
Top