ContentValues values = new ContentValues(); values.put("name", "John"); values.put("age", 25); if (values.containsKey("name")) { Log.d("TAG", "Name key exists"); } else { Log.d("TAG", "Name key does not exist"); }
ContentValues values = new ContentValues(); values.put("name", "John"); values.put("age", 25); if (values.containsKey("city")) { Log.d("TAG", "City key exists"); } else { Log.d("TAG", "City key does not exist"); }In this example, we perform the same steps as in Example 1, but we check for the existence of the "city" key instead of the "name" key. Since the "city" key does not exist in the ContentValues object, the message "City key does not exist" is logged to the console. The ContentValues class is included in the android.content package.