Android SQLite从表中删除行2个参数

这是我的数据库:

// the names for database columns public final static String TABLE_NAME = "vremena"; public final static String TABLE_COLUMN_ID = "_id"; public final static String TABLE_COLUMN_ONE = "dan"; public final static String TABLE_COLUMN_TWO = "vrijeme"; 

我试图创build一个方法,它需要2个参数,并从数据库中删除选定的行:

 public void delete(String dan, int vrijeme){ db.delete(TABLE_NAME, TABLE_COLUMN_ONE+"="+dan, TABLE_COLUMN_TWO+"="+vrijeme); } 

我得到这个错误:

 The method delete(String, String, String[]) in the type SQLiteDatabase is not applicable for the arguments (String, String, String) 

我知道我在删除方法中做错了什么。

  • 从SQLite延迟加载
  • 使用SimpleCursorAdapter从Cursor更改值
  • 从SQLite获取所有行
  • 在sqlite中的Android真正的转义string
  • 如何通过ORDER构建一个SQLite查询到GROUP?
  • SQLite数据库的版本号
  • SQLiteException:在编译时出现“”:语法错误(代码1)
  • 新行字符\ n在textView Android中不能正确显示
  • 看看API文档:

    http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html

     delete(String table, String whereClause, String[] whereArgs) Convenience method for deleting rows in the database. 

    你应该做这个:

     public void delete(String dan, int vrijeme){ db.delete(TABLE_NAME, TABLE_COLUMN_ONE + " = ? AND " + TABLE_COLUMN_TWO + " = ?", new String[] {dan, vrijeme+""}); }