如何删除SqliteDataBase中的行?

时间:2014-09-04 00:27:16

标签: android sql delete-row

您好我的应用程序中我想只删除具有相同年份和月份的行:

按月删除行:

public void deleteMonth(int month){
    open();
    myDb.delete(TABLE_DAY, "month = ?", new String[] {month+""});
    close();
}

但是为了按月和年删除行,它在这里崩溃是我试过的:

public void deleteMonth(int month ,int year){
    open();
    myDb.delete(TABLE_DAY, "month = ? , year = ?", new String[] {month+"",year+""});
    close();
}

我解决了:

public void deleteMonth(int month ,int year){
    open();
    myDb.delete(TABLE_DAY, "month = ? and year = ?", new String[] {month+"",year+""});
    close();
}

0 个答案:

没有答案