title: Use Insert or Replace in ContentProvider
body: <p>When I want to check and see if something exists in my <code>ContentProvider</code> what I usually do is something similar to this</p>
  
  <pre><code>Cursor c = getContentResolver().query(table,projection,selection,selectionArgs,sort);
  
  if(c != null &amp;&amp; c.moveToFirst()){
  
      //item exists so update
  
  }else{
  
      //item does not exist so insert
  
  }
  </code></pre>
  
  <p>but that means I always have to make possibly an unnecessary Database call slowing things down especially the greater number of checks on the database I need to do. There has to be a better way to handle this so I dont always have to query first.</p>
  
  <p>I looked at this question </p>
  
  <p><a href="https://stackoverflow.com/questions/4285266/android-contentprovider-update-within-an-insert-method">Android Contentprovider - update within an insert method</a></p>
  
  <p>but using <code>insertWithOnConflict</code> only checks the primary key id and in my case that will not work because what I am checking is not the id but a unique string from a server database.</p>
  
  <p>so is there something I can do with the Content Provider so I dont always have to make a query to check if the item exists in it already? </p>