/** Called when the activity is first created. */
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // открываем подключение к БД
    db = new DB(this);
    db.open();
    cursor = db.getAllData();
    startManagingCursor(cursor);
  }
 @Override
 public void onClick(DialogInterface dialog, int which, boolean isChecked) {
   ListView lv = ((AlertDialog) dialog).getListView();
   Log.d(LOG_TAG, "which = " + which + ", isChecked = " + isChecked);
   db.changeRec(which, isChecked);
   cursor.requery();
 }
 protected void onDestroy() {
   super.onDestroy();
   db.close();
 }