从用户词典android查询单词

时间:2014-03-17 10:13:19

标签: android dictionary

我正在尝试检查给定字符串是否为单词。为此,我试图从用户词典查询单词,但它返回2个字符串(甚至不是一个单词)。

cursor = getContentResolver().query(
                        UserDictionary.Words.CONTENT_URI, // The content URI of
                                                            // the words table
                        mProjection, // The columns to return for each row
                        null, // Either null, or the word the user
                                            // entered
                        null, // Either empty, or the string the user
                                        // entered
                        null);                      



             if (cursor.getCount() < 1) {
                    // Word is not in dictionary
                    Toast tst = Toast.makeText(getApplicationContext(),
                            "Word is not in dictionary ", Toast.LENGTH_SHORT);
                    tst.show();                     

                } else {
                    Toast tst = Toast.makeText(getApplicationContext(),
                            "Word is in dictionary", Toast.LENGTH_SHORT);
                    tst.show();
                    int index = cursor.getColumnIndex(UserDictionary.Words.WORD);

                    while (cursor.moveToNext()) {

                        // Gets the value from the column.
                   Log.i("words",""+cursor.getString(index));

                        // Insert code here to process the retrieved word.

而不是显示字典中的所有单词,它显示2个字符串。                             // while循环结束                         }                     }

0 个答案:

没有答案