Android Question How to check #FILENOTFOUND when loading image file?

FERNANDO SILVEIRA

Active Member
Licensed User
Hello guys,

I have the following code:
B4X:
bg = LoadBitmapResize(File.DirAssets, wWordOK & ".jpg", ImageView1.Width, ImageView1.Height, True)

What happen if the file is missing?
I'd like to test file existance and if the image is not there, load a default image instead.

Same doubt (file not found) reading text from a file.

Regards,
Fernando
 

Claudio Oliveira

Active Member
Licensed User
Longtime User
Just check if file exists before trying to access it.
B4X:
If File.Exists(File.DirAssets, wWordOK & ".jpg") then
   bg = LoadBitmapResize(File.DirAssets, wWordOK & ".jpg", ImageView1.Width, ImageView1.Height, True)
End if
 
Upvote 0
Top