Applications like ebook readers, crosswords and other word games may leverage on dictionary language packs to retrieve words and their definitions.
If you are an Android developer, you may enable your Android application to retrieve the meaning of a word from dictionary language packs installed on the same device. An application can get word definitions from a language pack by using the procedure described in Content Provider Basics. A dictionary language pack implements the standard content provider capabilities.
The query may be performed using getContentResolver().query(uri, null, null, selectionArgs, null)
Both uri and selectionArgs are mandatory in the query() method. Note that the other parameters are ignored in the current implementation.
The following content uri allows your application to retrieve the definition of a word:
The following content uri may be used to perform a search with partial match:
The provider's authority to be used in the content uri is:
Example: retrieve a word definition
Here is an example to retrieve italian definitions. Make sure to install the latest version of the italian language pack on your Android device.
General documentation about developing Android applications is available in Android Developers web site.
Let's start by defining some useful constants:
Now we do a simple query to retrieve the meaning of word 'pace':
The execution of the above code may result in the following output in the logcat:
found word: pace, definition: <span class=head>sostantivo</span> (<i>f sing, plurale:</i> paci)<ol><li>stato di <a href="quiete">quiete</a></li><li><small>(<i>militare</i>)</small> situazione in cui i <a href="conflitti">conflitti</a> vengono gestiti senza ricorrere alla <a href="violenza">violenza</a></li></ol><span class=head>sillabazione</span><dl><dt>pà | ce</dt></dl><span class=head>etimologia</span><ul><li>dal <a href="latino">latino</a> <i>pax</i>, con la radice pak- presente anche in <a href="patto">patto</a></li></ul><span class=head>contrari</span><ul><li><a href="guerra">guerra</a></li></ul>
Note1: the output provided by the DictionaryProvider is an html fragment. The exact content may change in future releases, anyway the content is taylored to be rendered using a WebView object instance.
Note2: in case the given word is not found in the dictionary, the DictionaryProvider may return some suggestions.