1. You should change the insert code to:
SQL1.BeginTransaction
For i = 0 To WordList.Size -1
word = WordList.Get(i)
SQL1.ExecNonQuery2("INSERT INTO word_list VALUES (?)", Array As Object(word))
Next
SQL1.TransactionSuccessful
SQL1.EndTransaction
It will be about 100 times faster.
2. You have added CustomListView code to the main activity. This is not needed. See CustomListView class example.
The algorithm is the king
My algorithm solves 8 characters in 10ms (10 milliseconds):
Private Sub CalcWordHash(w As String) As Int
Dim h As Int
For i = 0 To w.Length - 1
h = h + Asc(w.CharAt(i))
Next
Return h
End Sub
Sub FillSQLTable
Dim i As Int
Dim word As String
WordList.Clear
WordList = File.ReadList(File.DirRootExternal, "Jumble/WordList.txt")
Log("create")
SQL1.BeginTransaction
For i = 0 To WordList.Size -1
word = WordList.Get(i)
SQL1.ExecNonQuery2("INSERT INTO word_list VALUES (?, ?)", Array As Object(word, CalcWordHash(word)))
Next
SQL1.TransactionSuccessful
SQL1.EndTransaction
lb_results.Text = "Database Created"
End Sub
Sub SolveJumble
Dim start As Long = DateTime.Now
Dim w As String = tx_word.Text
Dim crsr As Cursor = SQL1.ExecQuery2("SELECT word FROM word_list WHERE hash = ?", _
Array As String(CalcWordHash(w)))
For i = 0 To crsr.RowCount - 1
crsr.Position = i
Dim test As String = crsr.GetString("word")
If test.Length = w.Length Then
Dim chars As List
chars.Initialize
For c = 0 To w.Length - 1
chars.Add(w.CharAt(c))
Next
For c = 0 To test.Length - 1
Dim charPos As Int = chars.IndexOf(test.CharAt(c))
If charPos = -1 Then Exit
chars.RemoveAt(charPos)
Next
If c = test.Length Then
Log("Found: " & test)
End If
End If
Next
crsr.Close
Log(DateTime.Now - start)
End Sub