पूर्वशर्त प्रयास करें,:
Settings
पर सुनिश्चित करें कि आप UserDictionary में उपयुक्त शब्द हैं ->Language & Input
->Personal dictionary
।
नमूना एसक्यूएल क्वेरी जो उपयोगकर्ता शब्दकोश में SO
वाले शब्दों की खोज करती है और यह समकक्ष एंड्रॉइड कोड नमूना है। ?
का उपयोग args
द्वारा प्रतिस्थापित करने के लिए नोटिस करें।
SQL क्वेरी:
SELECT UserDictionary.Words._ID, UserDictionary.Words.WORD FROM UserDictionary.Words.CONTENT_URI WHERE UserDictionary.Words.WORD LIKE "%SO%
समतुल्य कोड:
AndroidManifest.xml में
String[] columns = {UserDictionary.Words._ID, UserDictionary.Words.WORD};
String condition = UserDictionary.Words.WORD + " LIKE ? ";
// ? in condition will be replaced by `args` in order.
String[] args = {"%SO%"};
ContentResolver resolver = getContentResolver();
Cursor cursor = resolver.query(UserDictionary.Words.CONTENT_URI, columns, condition, args, null);
//Cursor cursor = resolver.query(UserDictionary.Words.CONTENT_URI, projection, null, null, null); - get all words from dictionary
if (cursor != null) {
int index = cursor.getColumnIndex(UserDictionary.Words.WORD);
//iterate over all words found
while (cursor.moveToNext()) {
//gets the value from the column.
String word = cursor.getString(index);
Log.i(TAG, "Word found: " + word);
}
}
अनुमतियां:
<uses-permission android:name="android.permission.READ_USER_DICTIONARY"/>
में अब उपलब्ध नहीं है। – Suragch