@OnClick(R.id.buttonUnique)
 void buttonUniqueClick() {
   Note note = noteDao.queryBuilder().orderAsc(NoteDao.Properties.Id).limit(1).unique();
   Log.d("note  ", note.getComment());
   noteDao.delete(note);
   cursor.requery();
   adapter.notifyDataSetChanged();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    staticHandlerPrint = new StaticHandlerPrint(this);
    startService();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            startService(new Intent(getBaseContext(), PrintNoteIntentService.class));
            //                Snackbar.make(view, "Replace with your own action",
            // Snackbar.LENGTH_LONG)
            //                        .setAction("Action", null).show();
          }
        });

    DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "notes-db", null);
    db = helper.getWritableDatabase();
    daoMaster = new DaoMaster(db);
    daoSession = daoMaster.newSession();
    noteDao = daoSession.getNoteDao();

    String textColumn = NoteDao.Properties.Test.columnName;
    String orderBy = textColumn + " COLLATE LOCALIZED ASC";
    cursor =
        db.query(noteDao.getTablename(), noteDao.getAllColumns(), null, null, null, null, orderBy);
    String[] from = {textColumn, NoteDao.Properties.Comment.columnName};
    int[] to = {android.R.id.text1, android.R.id.text2};
    adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, from, to);
    listView.setAdapter(adapter);

    listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            noteDao.deleteByKey(id);
            Log.d("Dao", "Deleted new note ,Id: " + id);
            cursor.requery();
            return false;
          }
        });
  }
  private void addNote() {

    for (int i = 0; i < 50; i++) {
      final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
      String comment = "Added on " + df.format(new Date());
      Note note = new Note(null, "AA" + i + "" + i + "" + i, comment, new Date());
      noteDao.insert(note);
      Log.d("Dao", "Inserted new note ,Id: " + note.getId());
      cursor.requery();
    }
    adapter.notifyDataSetChanged();
  }