title: Only allow unique data entry with Android SQLite?
body: <p>Before I get into describing by problem I'd like to point out I am aware of the other threads asking this question, however none for me have been able to solve my issue.</p>
  
  <p>I've been working on a sharing app using the BumpAPI, which upon receiving the chunk, saves it to an SQLite database for retrieval in a list view activity, this is all working fine and the data is saved, however if the same text is sent twice it will be saved again and again and the list view will show this, from what I've read I need the 'UNIQUE' identifier? however being completely new to SQL I am at a loss with regards to achieving this, here is my DataHelper class which im using to create and add the entries, would anyone be kind enough to modify it or inform me of a possible solution? </p>
  
  <p>Thanks very much</p>
  
  <pre><code>    public class DataHelper {
  
     private static final String DATABASE_NAME = "tags.db";
     private static final int DATABASE_VERSION = 1;
     private static final String TABLE_NAME = "TagTable";
  
     private Context context;
     private SQLiteDatabase db;
  
     private SQLiteStatement insertStmt;
     private static final String INSERT = "insert into "
        + TABLE_NAME + "(name) values (?)";
  
     public DataHelper(Context context) {
        this.context = context;
        OpenHelper openHelper = new OpenHelper(this.context);
        this.db = openHelper.getWritableDatabase();
        this.insertStmt = this.db.compileStatement(INSERT);
     }
  
     public long insert(String name) {
        this.insertStmt.bindString(1, name);
        return this.insertStmt.executeInsert();
  
     }
  
  
  
     public void deleteAll() {
        this.db.delete(TABLE_NAME, null, null);
     }
  
     public List&lt;String&gt; selectAll() {
        List&lt;String&gt; list = new ArrayList&lt;String&gt;();
        Cursor cursor = this.db.query(TABLE_NAME, new String[] { "name" }, 
          null, null, null, null, "name desc");
        if (cursor.moveToFirst()) {
           do {
              list.add(cursor.getString(0)); 
           } while (cursor.moveToNext());
        }
        if (cursor != null &amp;&amp; !cursor.isClosed()) {
           cursor.close();
        }
        return list;
     }
  
     private static class OpenHelper extends SQLiteOpenHelper {
  
        OpenHelper(Context context) {
           super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }
  
        @Override
        public void onCreate(SQLiteDatabase db) {
           db.execSQL("CREATE TABLE " + TABLE_NAME + "(id INTEGER PRIMARY KEY, name    TEXT)" + "text unique, " + "ON CONFLICT REPLACE");
        }
  
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
           db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
           onCreate(db);
        }
     }
  }
  </code></pre>