With UserDictionary.Words and WRITE_USER_DICTIONARY
permission it's possible to add words to the user dictionary, but I don't see any way to remove words.
The motivation in this case is to add autocompletion suggests that are local to the app and remove them when exiting the app, but I can also imagine something like an app that automatically removed typos that were accidentally added.
Is there any way to do this?
One possible solution is to remove the exact word(s) using ContentResolver.delete()
. Example:
private int deleteWord(String word) {
if (TextUtils.isEmpty(word)) {
return -1;
}
return getContentResolver().delete(UserDictionary.Words.CONTENT_URI,
UserDictionary.Words.WORD + "=?", new String[] { word });
}
And of course, need
<uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" />
defined in the manifest.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With