Android Question cant load image from sub folder in assetsdir

ShadTech

Member
Licensed User
cant load image from sub folder in assetsdir
and the folder is there when i checked it
it rises error
b4xpagepg2_clv1_visiblerangechanged (java line: 300)
java.io.FileNotFoundException: AssetsDir/Modern/Modern/Commercial/Hall/Hall Meating/fefa34a6a15f0644d07d80de030a5907.jpg: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:214)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.initializeSampleImpl(CanvasWrapper.java:601)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.InitializeResize(CanvasWrapper.java:548)
at anywheresoftware.b4a.keywords.Common.LoadBitmapResize(Common.java:1370)
at anywheresoftware.b4a.objects.B4XViewWrapper$XUI.LoadBitmapResize(B4XViewWrapper.java:699)
at com.AQ_Design.b4xpagepg2._clv1_visiblerangechanged(b4xpagepg2.java:300)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1178)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
... 19 more
any help
<<
img:
img.Bitmap = xui.LoadBitmapResize(File.DirAssets,"Modern/Modern/Commercial/Hall/Hall Meating/fefa34a6a15f0644d07d80de030a5907.jpg", p.Width / 2, p.Height+200, True)
 

MicroDrie

Well-Known Member
Licensed User
Longtime User
Don't mix up directories and filenames. A filename is only a filename. A directory name included all sub directories.
Directory name include sub directories:
    Dim DirStr As String = $"${File.DirDefaultExternal}/Modern/Modern/Commercial/Hall/Hall Meating"$
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Don't use subfolders inside the assets folder. It will only make things more difficult.
I agree.

You can (should?) create groups in the tab "Files manager":

1659375697276.png
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
can i load image from file manager using AssetDir or there is another way???
You must load files from File.DirAssets.


However, even if you create some groups as I showed you in my previous post, the files will still be in the only directory on PC: B4A/Files/. Let's say that groups can be considered virtual directories.

Note that those files can only be used for reading; so, for example, if you were to put a SQLite DB file in it, you could not work on that file directly, you would have to copy it (usually to the File.DirInternal) and work on that copy.
 
Upvote 0
Top