Android SQLite Remove row from table Where 2 arguments

This is my database:

// 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"; 

I am trying to create a method that takes 2 arguments and removes the selected row from the database:

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

We get this error:

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

I know that I am doing something wrong in the delete method.

+7
source share
1 answer

Take a look at the API Docs:

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. 

You must do this:

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

All Articles