I am using the following code to select a file using a ListView.
If there is no associated file, I get the following error:
B4X:
Sub lvNovels_ItemClick (Index As Int, Value As Object)
Dim PDF As String
PDF = Value
File.Copy(File.DirRootExternal, "/Books/" & PDF & ".pdf",File.DirInternal, "testbook.pdf" )
CacheDir = File.Combine(File.DirInternalCache, "images")
File.MakeDir("", CacheDir)
OpenFilePDF(File.Combine(File.DirInternal, "testbook.pdf"))
End Sub
How can I "trap" this error to display a Toastmessage that the book is unavailable?java.io.FileNotFoundException: /storage/emulated/0/Books/9780797815506.pdf: open failed: ENOENT (No such file or directory)