title: SQLite "database schema has changed" error in Content Provider
body: <p>I'm using <code>Content Providers</code> and <code>Sync Adapters</code> for my synchronization routine.</p>
  
  <p>My routine receives a <code>JSONObject</code> and insert or update the entry.</p>
  
  <p>In order to decide if we are going to update or insert we check if the entry exists in the database. This is where the sqlite error occurs.</p>
  
  <pre><code>06-03 10:58:21.239: INFO/Database(340): sqlite returned: error code = 17, msg = prepared statement aborts at 45: [SELECT * FROM table WHERE (id = ?) ORDER BY id]
  </code></pre>
  
  <p>I have done some research and found <a href="http://comments.gmane.org/gmane.comp.db.sqlite.general/1747" rel="nofollow">this</a> discussion about the subject. From this discussion I understand that <code>sqlite_exec()</code> has to be called. How would I implement this in a Content Provider?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Insert / Update check</p>
  
  <pre><code>// Update or Insert
  ContentValues cv = new ContentValues();
  /* put info from json into cv */
  if(mContentResolver.update(ClientsProvider.CONTENT_URI, cv, null, null) == 0) {
      // add remote id of entry
      cv.put("rid", o.optInt("id"));
      mContentResolver.insert(ClientsProvider.CONTENT_URI, cv);
  }
  </code></pre>
  
  <p>ContentProvider::update</p>
  
  <pre><code>@Override
  public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
      int count = 0;
      switch(uriMatcher.match(uri)) {
      case CLIENTS:
          count = clientDB.update(TABLE_NAME, values, selection, selectionArgs);
          break;
      case CLIENT_ID:
          count = clientDB.update(TABLE_NAME, values, ID + " = " + uri.getPathSegments().get(0) + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs);
          break;
      default:
          count = 0;
      }
      return count;
  }
  </code></pre>