10

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'm trying to create a method which takes 2 arguments and deletes a selected row from the database :

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

Am getting this error :

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

I know I'm doing something wrong within delete method.

1 Answer 1

27

Have 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 should do this:

public void delete(String dan, int vrijeme){
    db.delete(TABLE_NAME, 
            TABLE_COLUMN_ONE + " = ? AND " + TABLE_COLUMN_TWO + " = ?", 
            new String[] {dan, vrijeme+""});
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.