I am using UserDictionary.Words class's addWord function to add Words to Dictionary so that they can show up in Text prediction. The Words do exist in the dictionary with APP_ID=0
and available for default android keyboard.
However I am using Swift keyboard and it is not considering those words for Prediction.
I am using this TUTORIAL
UserDictionary.Words.addWord(this, "ThisIsSomeWordIwantForPrediction", 250, null, Locale.getDefault());
My question is how can I add words such that they are available for prediction for all keyboards
You are doing the right thing to make the words available, but as you have found, not all keyboards are reading from the system dictionary content provider.
That's a question you need to address to Swiftkey, as to why their keyboard does not use the system provided word list.
(Similarly, not all web browser apps make use of the system provided bookmark storage, and messaging apps like whatsapp provide their own storage solution, rather than making use of the inbuilt SMS storage provider).
来源:https://stackoverflow.com/questions/31660006/issue-programmatically-adding-word-for-word-prediction