title: How do I get "insert or update" behaviour without using CONFLICT_REPLACE?
body: <p>My Android app is using an SQLite FTS3 table to provide full text search. I'm using <code>insertWithOnConflict</code> with <code>CONFLICT_REPLACE</code> to update my database, inserting a new row if need be or updating an existing row if it's present.</p>
  
  <p>I was very surprised to find that my table ended up containing duplicate rows &mdash; but it looks like this is a documented "feature" of SQLite's FTS modules:</p>
  
  <p>From the <a href="http://www.sqlite.org/fts3.html" rel="nofollow">SQLite FTS3 and FTS4 Extensions</a> page:</p>
  
  <blockquote>
    <p>Datatypes and column constraints are specified along with each column.
    These are completely ignored by FTS and SQLite.</p>
  </blockquote>
  
  <p>It's pretty easy to replicate the duplication from the command line:</p>
  
  <pre><code>sqlite&gt; CREATE VIRTUAL TABLE test_duplicates USING FTS3
     ...&gt; (id INTEGER PRIMARY KEY, name TEXT);
  sqlite&gt; INSERT INTO test_duplicates (id, name) VALUES (1, "George");
  sqlite&gt; INSERT INTO test_duplicates (id, name) VALUES (1, "George");
  sqlite&gt; INSERT OR REPLACE INTO test_duplicates (id, name) VALUES (1, "George");
  sqlite&gt; SELECT * FROM test_duplicates;
  1|George
  1|George
  1|George
  sqlite&gt;
  </code></pre>
  
  <p>My question is: what's the best (simplest, most robust) way to replicate the behaviour of <code>CONFLICT_REPLACE</code>?</p>
  
  <p>My ideas at the moment are either to (A) do a SELECT, then an UPDATE or INSERT based on the result or (B) blindly try DELETE the existing row (which may or may not be present) and then INSERT.</p>