我在删除数据库时单击按钮,我的删除方法如下
public int deleteDatabase(String tableName) {
SQLiteDatabase db = database.getWritableDatabase();
String whereClause = null; // delete all rows
String[] whereArgs = { null };
int count = db.delete(tableName, whereClause, whereArgs);
db.close();
return count;
}
if (DatabaseHelper.getInstance(getApplicationContext())
.isTableExists(MY_TABLE)) {
Log.d(TAG, "Table exist, delete database");
deleteDatabase(MY_LIST_TABLE);
}
,错误如下:绑定参数太多。提供了1个参数,但该语句需要0个参数。
答案 0 :(得分:4)
String whereClause = null; // delete all rows
String[] whereArgs = { null };
int count = db.delete(tableName, whereClause, whereArgs);
如果您提供whereArgs,则还必须提供有效的where子句(使用?
占位符)。改变它
int count = db.delete(tableName, null, null);