Adding to the Android User Dictionary


On Android there is a single UserDictionary that works across all keyboards, and any app (with the appropriate permissions) can query, add and remove words. Here is some simple code to add a word to the dictionary (via XE8):
Androidapi.JNI.Provider, Androidapi.Helpers, Androidapi.JNI.JavaTypes;

procedure AddUserWord(const AWord: string);
// Need WRITE_USER_DICTIONARY permission
SharedActivityContext, // Context
StringToJString(AWord),// Word to add
255, // Frequency: 1- 255
nil, // optional shortcut

If you also want to read the dictionary then you need to have the READ_USER_DICTIONARY permission. Check out the documentation for more information on the UserDictionary and it’s Words list.

Comments are closed.