从表onClickListener中删除

时间:2013-05-27 00:10:36

标签: android sqlite android-sqlite sql-delete

 delete.setOnClickListener(new OnClickListener(){

                @Override
                public void onClick(View v) {
                    Cursor c= myDB.rawQuery("DELETE FROM contacts where id_ctc='"+t+"'",null);
                    Intent i = new Intent(Dial.this,TabLayout.class);
                    startActivity(i);
                }         
              });

应用程序停止工作(不幸的是,Tablayout已停止。)

1 个答案:

答案 0 :(得分:1)

public void onClick(View v) {
    myDB.delete(TABLE_CONTACTS, id_ctc + " = ?", new String[] { String.valueOf(t) });
    Cursor c= myDB.rawQuery("DELETE FROM contacts where id_ctc='"+t+"'",null);
    Intent i = new Intent(Dial.this,TabLayout.class);
    startActivity(i);
}