How to check if a word is available in a user dictionary?

I need the simplest and most elegant way (having a word) to check if a given word is available in a user dictionary or not. The frequency of words doesn't matter, locale does.

Is there something simpler than requesting a ContentResolver iterate and validate with cursor.getString(INDEX_WORD).equals(myWord) ?

+4
source share
1 answer

You must create a query that will search for your word in UserDictionary :

 getContentResolver().query(UserDictionary.Words.CONTENT_URI, new String[]{UserDictionary.Words._ID, UserDictionary.Words.WORD}, //Selection UserDictionary.Words.WORD +" = ?", //Selection args new String[]{myWord}, null); 

Than you can check Cursor :

 if(cursor.getCount()==0){ //Word is not in dictionary } 
+2
source

All Articles