5

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?

blahdiblah
  • 33,069
  • 21
  • 98
  • 152

1 Answers1

6

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.

ozbek
  • 20,955
  • 5
  • 61
  • 84
  • Can you please help me in this.. http://stackoverflow.com/questions/31660006/issue-programatically-adding-word-for-word-prediction? – Quamber Ali Jul 27 '15 at 18:29