EDIT :
I've followed your good advices and I've used a trie data structure to contain my dictionnary. The structure I have chosen is this one for interested peoples.
But for now I've another issue : the construction of my trie data structure each time I launch my application is very too long ! Maybe my dictionnary is too huge, or maybe the implementation of trie I've chosen is too not appropriate for a simple dictionnary.
So is there a way to conserve this structure even after closing the app like a registered database or if you think the issue is caused by the implementation can you recommend me another one ?
I've got a serious issue with my android's project.
The goal here is to calculate all the words that can be made with a serie of 6 letters
To do that, I've two table in my BDD :
- 'words' with two columns : '_id'and 'mots'
- and 'temp' a temporary table with the same columns.
'words' contains all the words of vocabulary (it's huge) and 'temp' contains all the possible combinations of letters that can be made with the 6 letters (3 letters used at least).
I'm tryng to select in the table 'temp' the word which are real so the one which are in the table 'words'. Here is my code to do that :
I do a first selection of the words which contain the good letters (at least 3 letters are used)
db.execSQL("CREATE TABLE temp2 (_id integer primary key autoincrement, mots text not null);");
db.execSQL("INSERT INTO temp2 (_id, mots) SELECT * FROM words WHERE mots like '%"+lettres.tab_char.get(0)+"%' OR mots like '%"+lettres.tab_char.get(1)+"%' "
+ "OR mots like '%"+lettres.tab_char.get(2)+"%' OR mots like '%"+lettres.tab_char.get(3)+"%' OR mots like '%"+lettres.tab_char.get(4)+"%' "
+ "OR mots like '%"+lettres.tab_char.get(5)+"%';");
(lettre.tab_char is an ArrayList(Character) which contains the letters used to make the combinations in temp)
I do a join between the tables 'temp2' and 'temp' :
String MY_QUERY = "SELECT temp2._id, temp2.mots FROM temp2 INNER JOIN temp ON temp2.mots = temp.mots;";
Cursor test = db.rawQuery(MY_QUERY, null);
After that I put my values into a listview.
It works but it's really really slow : Can you help me please ?