Skip to content Skip to sidebar Skip to footer

Fastest Method To Insert Words Into Userdictionary

I would like app to add several (2k) words to UserDictionary. I have experimented with ContentResolver().insert/bulk insert.... // array of words String[] words = getResources

Solution 1:

Specific to your case: Adding 2000 words in the dictionary at a stretch will take time and there is not much of an optimization which can be done. The time you see here are for the file operation and moving from Java->NDK->Native operation.

General: Irrespective of the method used, one has to understand that these are nothing but file operations and is bound to take time. The APIs (including SQLite related) are just a wrapper to the intended file operations in the native code. Natively file write will always take a longer time then file read.

Solution 2:

I've saw in the sources of Android that for large sql queries applyBatch method is used. In some other programs as ContactsRemover the authors also use this method. But I do not know if it is really faster then insert or bultInsert.

Post a Comment for "Fastest Method To Insert Words Into Userdictionary"