title: Android ContentResolver.update() produces duplicates
body: <p>I have worked with ContentProviders in previous projects and this has always worked for me however I can't get my head around the problem this time. When I run a update() using a Content Resolver it duplicates the object in the database instead of updating it. </p>
  
  <p>Here is the code the fires the update. It only includes the required updated data in the ContentValues not a whole repeat of the object. The index variable in the where statement is the row number of the object in the database, this index is correct.</p>
  
  <pre><code>ContentValues cv = new ContentValues();
  cv.put(MessageProvider.KEY_MESSAGE_STATUS, m.getStatus());
  cr.update(MessageProvider.CONTENT_URI_MESSAGE, cv, MessageProvider.KEY_ID + "=" + index, null);
  </code></pre>
  
  <p>I do not believe this code is at fault as I have tried changing this and it still produces the same duplication. My alternative was to include the row index in the Uri.</p>
  
  <p>This is the code from the Content Provider.</p>
  
  <pre><code>@Override
  public int update(Uri uri, ContentValues values, String where,
          String[] whereArgs) {
  
      int count = 0;
      String whereString;
  
      switch (uriMatcher.match(uri)) {
      case MESSAGE:
          count = messageDB.update(MESSAGE_TABLE, values, where, whereArgs);
          break;
  
      case MESSAGE_ID_:
          String segment = uri.getPathSegments().get(1);
  
          if (!TextUtils.isEmpty(where)) {
              whereString = " AND (" + where + ')';
          } else {
              whereString = "";
          }
  
          count = messageDB.update(MESSAGE_TABLE, values, KEY_ID + "="
                  + segment + whereString, whereArgs);
          break;
  
      default: throw new IllegalArgumentException("Unsupported URI " + uri);
  
      }
  
      getContext().getContentResolver().notifyChange(uri, null);
      return count;
  }
  </code></pre>
  
  <p>Nothing jumps out at me here as being incorrect but I'm sure more expert eyes will be able to help! Many thanks!</p>