title: Android Sqlite: Check if row exists in table
body: <p>I have an array of strings that need to be checked if exists in a table before inserting them in order to avoid duplicates. What is the SQL query and how do I substitute the following values to it? :)</p>
  
  <pre><code>ArrayList&lt;Product&gt; NewProducts= new ArrayList&lt;Product&gt;();
  </code></pre>
  
  <p><strong>My Product Model:</strong></p>
  
  <pre><code>public class Product {
      public Product()
      {
  
      }
  
      public String PID = "pid";
      public String getPID() {
          return PID;
      }
      public void setPID(String pID) {
          PID = pID;
      }
      public String getNAME() {
          return NAME;
      }
      public void setNAME(String nAME) {
          NAME = nAME;
      }
  
      public String PID = "pid";
      public String NAME = "name";
  }
  </code></pre>
  
  <p><strong>Table name:</strong> product_pics</p>
  
  <p><strong>Database name:</strong> product_db</p>
  
  <p>I understand that this statement will work:</p>
  
  <pre><code>"SELECT * FROM ' + product_pics + ' WHERE PID=' + pid +'"
  </code></pre>
  
  <p>How do I properly format this such that the method returns if the product exists or not?</p>