Need help getting rid of this error. I am using code below to list a directory on my droid, then read each file and delete after reading them. When the directory is empty I get an error "java.io.IOException: Invalid argument" I know I am causing this by trying to read an empty array, just not sure how to get rid of it. I want the code to continue of the dir is empty. Any ideas?
B4X:
Dim Grabbed As String
LocalFiles = File.ListFiles (localDir) 'LocalDir is my droid inbox directory
For i = 0 To LocalFiles.Size-1
Activity.Title = LocalFiles.Size & " Returns Waiting"
Grabbed = LocalFiles.Get (i)
Next
ListView1.Visible = False 'hide the listview which is my menu page
lbl1.Visible = True 'show the text label for text file
lbl1.Text = File.ReadString(localDir, Grabbed) ' read the first text file
File.Delete(localDir, Grabbed) 'delete the file after it is read
End If