title: Delete Duplicates From SQLite Database
body: <p>I'm a complete SQL noob (never actually used it before) and I need to delete duplicates from a database, which I'm posting the code for below. Duplicate rows are exactly the same except for a unique ID. </p>
  
  <pre><code>public class PostsDatabaseHelper extends SQLiteOpenHelper {
  private static final String DB_NAME = "facebookPosts.sqlite";
  private static final int VERSION = 2;
  private static final String TABLE_POST = "post";
  
  public PostsDatabaseHelper(Context context){
      super(context, DB_NAME, null, VERSION);
  }
  
  @Override 
  public void onCreate(SQLiteDatabase db){
      db.execSQL("create table post(_id integer primary key autoincrement, filler string, post_id integer,"
              + "application string, caption string, created_time int, description string, from_ string, fromId string,"
              + "link string, message string, name string, picture string, place string, story string, to_ string)");
  }
  
  public void deleteDuplicates(){
      getWritableDatabase().rawQuery("DELETE FROM post WHERE post._id NOT IN (SELECT MIN(post._id) FROM post GROUP BY post.post_id", null);
  }
  }
  </code></pre>
  
  <p>I've looked at many other threads and tried their answers, but it still doesn't work (it's probably some misunderstanding of the syntax). Thoughts?</p>