Userdictionary.Word.APP_ID

I am using a content provider in Android using UserDictionary.

I inserted the lines as follows

public void insertData(String text){ Log.d(TAG, "App Name: "+getResources().getString(R.string.app_name)); mNewValues = new ContentValues(); mNewValues.put(UserDictionary.Words.APP_ID, getResources().getString(R.string.app_name)); mNewValues.put(UserDictionary.Words.LOCALE, getResources().getString(R.string.locale)); mNewValues.put(UserDictionary.Words.WORD, text); mNewValues.put(UserDictionary.Words.FREQUENCY, "100"); mNewUri = getContentResolver().insert( UserDictionary.Words.CONTENT_URI, mNewValues); getInsertedData(); } 

Reading the dictionary is as follows

  public void getInsertedData(){ mCursor = 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, null); if (null == mCursor) { Log.d(TAG, "Cursor Null"); } else if (mCursor.getCount() < 1) { Log.d(TAG, "Cursor Empty"); } else { if (mCursor.moveToFirst()){ do{ String word = mCursor.getString(mCursor.getColumnIndex(UserDictionary.Words.WORD)); String appName = mCursor.getString(mCursor.getColumnIndex(UserDictionary.Words.APP_ID)); }while(mCursor.moveToNext()); } mCursor.close(); } } 

But when I register the output of UserDictionary.Words.APP_ID (as selected from the cursor object), it gives me a value of 0 (zero). UserDictionary.Words.WORD gives the correct result, which is the entered words.

My question is why why UserDictionary.Words.APP_ID gives the value 0 and how do I get the name of the application?

+4
source share

Source: https://habr.com/ru/post/1489725/


All Articles