title: How to check if record already exists in SQLite table
body: <p>This is my <code>database</code></p>
  <pre><code>public void DBCreate() {
      SQLITEDATABASE = getActivity().openOrCreateDatabase(&quot;FavoritesDB&quot;, Context.MODE_PRIVATE, null);
      SQLITEDATABASE.execSQL(&quot;CREATE TABLE IF NOT EXISTS favorite(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, word VARCHAR, meaning VARCHAR);&quot;);
  }
  </code></pre>
  <p>This is how I am creating new rows:</p>
  <pre><code>String query = &quot;INSERT INTO favorite (word,meaning) VALUES('&quot;+wordd+&quot;', '&quot;+mean+&quot;');&quot;;
  Cursor c=SQLITEDATABASE.rawQuery(&quot;SELECT * FROM favorite WHERE id=?&quot;, null);
  if (c.moveToFirst())
  {      
        Toast.makeText(getActivity(),&quot;inserted&quot;,Toast.LENGTH_LONG).show();
                      SQLITEDATABASE.execSQL(query);
  }
  else
  {
        Toast.makeText(getActivity(),&quot;exists&quot;,Toast.LENGTH_LONG).show();
  }
  </code></pre>
  <p>How to check data before inserting value into table?</p>