Android Question File.exists is very slow in release mode and ok in debug mode

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Hi, I'm using File exists in a loop checking if it exists to use the record image or if it does not exists use a generic image.

B4X:
    If File.Exists(File.DirAssets,IzProd&"_img.png") = True Then
'        bmp = LoadBitmap(File.DirAssets, IzProd&"_img.png")    
'    Else
'        bmp = LoadBitmap(File.DirAssets, "NoImage.png")    
    End If

As you can see I've commented all except the if file.exists trying to find the problem.

Compiling in Debug mode it works ok, in release mode it works very very slow.

This is using b4a 5.20

Any idea of how to solve this?
Thanks
 

Ohanian

Active Member
Licensed User
Longtime User
Hi
try to use a try catch to load images.
i had the same problem.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
I did experience the same issue.
When loading a page that issues multiple calls to File.Exists it took couple of seconds to load ( on average over 100mSec per call )

The suggestion below eliminated the issue

In debug mode the asset files are not packed inside the APK so it is faster to access them.

You know which files exist in File.DirAssets. You can create a text file with all the files, read it with File.ReadList and then check whether the file exist based on this list.
 
Upvote 0
Top