Hi!
I have created a little function for my Lipapa Marte for Android app in order to delete all files witch have no entries in the db (orphan books and covers). I navegate for all folders and subfolders, recursively, and all is fine and works well, but I have about 11.000 books, and, it don't mind why, about 8.000 files that the application has to delete.
For every file I first check if it's a folder (if it's, I make a recursive call to the function), and if it's a conventional file, I have to search it in the database, in order to see if it's name appears in a record.
Here I've got a performance problem, because I have to make about 19.000 select calls, and it takes about one hour to execute.
This is the code:
I know it's possible to make parametrized sqlite sentences but, are they accepted in B4A? What's the syntax I've to write in order they work?
Thank you in advance.
I have created a little function for my Lipapa Marte for Android app in order to delete all files witch have no entries in the db (orphan books and covers). I navegate for all folders and subfolders, recursively, and all is fine and works well, but I have about 11.000 books, and, it don't mind why, about 8.000 files that the application has to delete.
For every file I first check if it's a folder (if it's, I make a recursive call to the function), and if it's a conventional file, I have to search it in the database, in order to see if it's name appears in a record.
Here I've got a performance problem, because I have to make about 19.000 select calls, and it takes about one hour to execute.
This is the code:
B4X:
Sub QuitarHuerfanos(Ruta As String)
Dim i As Int
Dim Fich As List
Dim CurHuer As Cursor
Dim Consulta As String
Dim Cadena As String
lbOptHuerfanosC.Text = Ruta
DoEvents
Fich = File.ListFiles(Ruta)
For i= 0 To Fich.Size - 1
If File.IsDirectory(Ruta, Fich.Get(i)) Then
QuitarHuerfanos(Ruta&Fich.Get(i)&"/")
Else
Cadena = Fich.Get(i)
Consulta = "SELECT NUMERO From LIBROS Where RUTAPAPYRE like '%" & Cadena.Replace("'", "?") & "'"
CurHuer = BDLIPAPA.ExecQuery(Consulta)
If CurHuer.RowCount = 0 Then
If File.Delete(Ruta, Fich.Get(i)) Then
ContaHuerfanos = ContaHuerfanos + 1
End If
End If
CurHuer.Close
End If
Next
End Sub
I know it's possible to make parametrized sqlite sentences but, are they accepted in B4A? What's the syntax I've to write in order they work?
Thank you in advance.